#1   Report Post  
Lang
 
Posts: n/a
Default Variables in Excel

Hi,

I'm having a hard time figuring out how to set a variable in a macro equal
to the value in a cell. I then want to be able to use that value with the
select method to select a number of rows equal to the value of my variable.

The big problem for me is going from the spreadsheet to the macro with a
value.
Any help appreciated.

Thanks,

Lang
  #3   Report Post  
Lang
 
Posts: n/a
Default Variables in Excel

thanks for the reply Don! I didn't get a chance to check this today, but
will try soon.

Lang

"Don Guillett" wrote:

will this work?

Sub selectrows()
Rows("1:" & Range("b10")).Select
End Sub

--
Don Guillett
SalesAid Software

"Lang" wrote in message
...
Hi,

I'm having a hard time figuring out how to set a variable in a macro equal
to the value in a cell. I then want to be able to use that value with the
select method to select a number of rows equal to the value of my

variable.

The big problem for me is going from the spreadsheet to the macro with a
value.
Any help appreciated.

Thanks,

Lang




  #4   Report Post  
i-Zapp
 
Posts: n/a
Default Variables in Excel


to use the value of a range (cell) in a macro, use the syntax:

Code:
--------------------
myvalue = range("a1").value
--------------------

where "a1" is value of interest.
then, to select a row use

Code:
--------------------
rows(myvalue).select
--------------------

to select that row number, or

Code:
--------------------
Rows(startrow & ":" & startrow+myvalue).select
--------------------

to select that number of rows


--
i-Zapp
------------------------------------------------------------------------
i-Zapp's Profile: http://www.excelforum.com/member.php...fo&userid=5768
View this thread: http://www.excelforum.com/showthread...hreadid=478768

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Urgent Help Required on Excel Macro Problem Sachin Shah Excel Discussion (Misc queries) 1 August 17th 05 06:26 AM
Display form from an VB application in Excel kuhni Excel Discussion (Misc queries) 0 August 10th 05 06:04 PM
How do you define variables in excel? BigRon Excel Discussion (Misc queries) 6 April 16th 05 08:47 PM
Hints And Tips For New Posters In The Excel Newsgroups Gary Brown Excel Worksheet Functions 0 April 15th 05 05:47 PM
Excel 2002 and 2000 co-install. Control Which Starts ? cnuk Excel Discussion (Misc queries) 2 January 17th 05 08:07 PM


All times are GMT +1. The time now is 01:46 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"