+ Reply to Thread
Results 1 to 3 of 3

How do you access cell's contents via a variable containing cell address??

Hybrid View

  1. #1
    Registered User
    Join Date
    01-29-2009
    Location
    Denver, Colorado
    MS-Off Ver
    Excel 2003
    Posts
    21

    How do you access cell's contents via a variable containing cell address??

    How can you access a cell's value via a vb variable that contains the cell's address.

    I have a vb variable named cellAddress (string) that contains "$A$1" and I want to assign the contents of what cellAddress points to another VB variable - how do i Do this?

    e.g. if cellAddress = "$a$1" and A1 contains "xyz", I would like to assigne "xyz" to a new vaiable by referencing just cellAddress???


    Also - Can anyone reccomend a good Excel VB book? A book that maybe stresses the VB language rather then a cook-book approach. I work in an area where I can't reference the internet for help unless I go to another building so i need a good book.

    Thanks,
    George

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: How do you access cell's contents via a variable containing cell address??

    Hello George,

    Use your variable that contains "$A$1" as the argument in a Range. The problem here is the range will always refer to the active sheet unless you qualify the Range reference with the worksheet.
      Dim Addx As String
      Dim NewData As Variant
    
        Addx = "$A$1"
       'This will always retrieve the contents of the ActiveSheet cell "$A$1"
        NewData = Range(Addx)
    
       'This will always retrieve the contents of Sheet3 cell "$A$1"
        NewData = Worksheets("Sheet3").Range(Addx)
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Registered User
    Join Date
    01-29-2009
    Location
    Denver, Colorado
    MS-Off Ver
    Excel 2003
    Posts
    21

    Re: How do you access cell's contents via a variable containing cell address??

    Leith - Thats' it, thanks,

    George

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1