ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Dumb Dim Question (https://www.excelbanter.com/excel-programming/302547-dumb-dim-question.html)

Michael Smith

Dumb Dim Question
 
I have what is probably a simple dim question....

I have set a variable....
Dim MyVar
MyVar = Range("AG1").Text

Now I want to select a range of rows from the 2nd row to the row# that
is my variable. (EX.(If MyVar is 10, then I want to select rows 2 thru
10)

I tried..
Rows("2:MyVar").Select
and it obviously failed with a type mismatch.

Thanks in advance!
-Mike

*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!

Chip Pearson

Dumb Dim Question
 
Michael,

Try

Rows("2:" & MyVar).Select


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"Michael Smith" wrote in message
...
I have what is probably a simple dim question....

I have set a variable....
Dim MyVar
MyVar = Range("AG1").Text

Now I want to select a range of rows from the 2nd row to the

row# that
is my variable. (EX.(If MyVar is 10, then I want to select

rows 2 thru
10)

I tried..
Rows("2:MyVar").Select
and it obviously failed with a type mismatch.

Thanks in advance!
-Mike

*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!





All times are GMT +1. The time now is 02:11 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com