Simple (I think) VBA syntax question
Amazing chart utilities from Jon Peltier
Thanks Thanks:  0
Likes Likes:  0
Results 1 to 4 of 4

Thread: Simple (I think) VBA syntax question

  1. #1
    Board Regular
    Join Date
    Feb 2002
    Location
    Southfield,MI USA
    Posts
    2,305
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

     
    Hey all,

    Kind of a general syntax question but it's simple enough to explain. This may remind you of the INDIRECT function.

    The Brief History:
    Somewhere in my current code I have an Object Variable (I'll call "x") that eventually gets assigned an integer value (via a calculation). The code I have so far to get this integer value works great. My question relates to the next step.

    By design, the end value for X is actually a row number. For example sake, say the current code ends in setting X = 34. What I'd like to do is use that Object Variable as a way to select a cell in Column B (B34 in this example). How do you code this?

    I've tried (with dismal failure) code similar to this:

    Range("B:"&X).Select (or)
    Range(""B:"&X").Select

    ...I know I'm missing something really basic - but I'm starting to go NUTS!

    Thanks!
    Adam S.

  2. #2
    Board Regular
    Join Date
    Feb 2002
    Location
    Chippenham, UK
    Posts
    136
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    On 2002-02-27 13:44, Asala42 wrote:
    Hey all,

    Kind of a general syntax question but it's simple enough to explain. This may remind you of the INDIRECT function.

    The Brief History:
    Somewhere in my current code I have an Object Variable (I'll call "x") that eventually gets assigned an integer value (via a calculation). The code I have so far to get this integer value works great. My question relates to the next step.

    By design, the end value for X is actually a row number. For example sake, say the current code ends in setting X = 34. What I'd like to do is use that Object Variable as a way to select a cell in Column B (B34 in this example). How do you code this?

    I've tried (with dismal failure) code similar to this:

    Range("B:"&X).Select (or)
    Range(""B:"&X").Select

    ...I know I'm missing something really basic - but I'm starting to go NUTS!

    Thanks!
    Adam S.
    Range("B:"&X).Select ' should work without the Colon

    Range("B"&X).Select ' or use.Activate

    If you are still having problems try stepping through the code to make sure that the variable x IS being assigned a value.




    Regards,

    Gary Hewitt-Long

  3. #3
    Board Regular
    Join Date
    Feb 2002
    Location
    Southfield,MI USA
    Posts
    2,305
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    That **** Colin!!

    Thanks, man. I was going Crazy!

  4. #4
    Board Regular
    Join Date
    Feb 2002
    Location
    Southfield,MI USA
    Posts
    2,305
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

      
    Colin = Colon

    I was so happy you posted my answer I forgot how to spell!

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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

 

 
DMCA.com