Google Answers Logo
View Question
 
Q: Excel macro question ( Answered 5 out of 5 stars,   0 Comments )
Question  
Subject: Excel macro question
Category: Computers > Software
Asked by: macaonghus-ga
List Price: $2.00
Posted: 24 Oct 2004 09:13 PDT
Expires: 23 Nov 2004 08:13 PST
Question ID: 419319
I am cycling through x = 1 to 100. I want to say something like

For x = 1 to 100
Range("Jx").Select
Next x

so it selects J1 then J2 then J3 etc. 

How can I use a value (x) instead of hard coding 1,2,3,4,5 .....

Thank you.
Answer  
Subject: Re: Excel macro question
Answered By: aht-ga on 24 Oct 2004 10:09 PDT
Rated:5 out of 5 stars
 
macaonghus-ga:

In your specific example, you will want to use the Offset method of
the Range class. The best reference for this is the Help file in Excel
VBA, so bring up Help when you are editing your macro (hit F1 to bring
it up), and just type "Offset" in the Index Search field.

In your example, you would have:

  For x = 0 to 99

    Range("J1").Offset(x,0).Select

    <your other code goes here>

  Next x


That's all!

Regards,

aht-ga
Google Answers Researcher
macaonghus-ga rated this answer:5 out of 5 stars

Comments  
There are no comments at this time.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy