Results 1 to 5 of 5

Thread: [RESOLVED] Excel - VBA

  1. #1

    Thread Starter
    Frenzied Member TomGibbons's Avatar
    Join Date
    Feb 2002
    Location
    San Diego, CA Previous Location: UK
    Posts
    1,345

    [RESOLVED] Excel - VBA

    How can I specify a cell to use as input and output? I am pretty new to VBA in excel
    Last edited by TomGibbons; Oct 15th, 2002 at 01:35 PM.

  2. #2
    Evil Genius alex_read's Avatar
    Join Date
    May 2000
    Location
    Espoo, Finland
    Posts
    5,538
    What are you trying to do here Tom, can you give me an idea of your project as I'm not sure what you're trying to achieve here.

    Thanks

    Please rate this post if it was useful for you!
    Please try to search before creating a new post,
    Please format code using [ code ][ /code ], and
    Post sample code, error details & problem details

  3. #3

    Thread Starter
    Frenzied Member TomGibbons's Avatar
    Join Date
    Feb 2002
    Location
    San Diego, CA Previous Location: UK
    Posts
    1,345
    It's pretty simple, I'm just not very good at explaining. I want to get text from, and put text in a cell that I know the co-ords of.
    Last edited by TomGibbons; Mar 11th, 2004 at 05:48 PM.

  4. #4
    Evil Genius alex_read's Avatar
    Join Date
    May 2000
    Location
    Espoo, Finland
    Posts
    5,538
    ahhh, okay, there's 2 main ways of doing this, either using the Range object, or the Cells object. I personally prefer using the range as it's easier.

    To run these, open Excel & add a button onto the spreadsheet. Double click onto the button to get to the code window & enter the following code.

    Using the range, you specify the letter of the column & the row number, so the first cell is referenced as A1. This returns a value in a messagbox for you.
    VB Code:
    1. Private Sub CommandButton1_Click()
    2.     MsgBox Sheets("Sheet1").Range("A1").Value
    3. End Sub

    The cells way works backwards, you specify a number for the row first, followed by a number for the column, both of these make up a reference to a cell - so the first cell will be referenced as 1,1. This sample places a value into the cell:
    VB Code:
    1. Private Sub CommandButton1_Click()
    2.     Sheets("Sheet1").Cells(1, 1).Value = "A Value"
    3. End Sub

    Please rate this post if it was useful for you!
    Please try to search before creating a new post,
    Please format code using [ code ][ /code ], and
    Post sample code, error details & problem details

  5. #5

    Thread Starter
    Frenzied Member TomGibbons's Avatar
    Join Date
    Feb 2002
    Location
    San Diego, CA Previous Location: UK
    Posts
    1,345
    Thanks alot Alex

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width