Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Selecting Rows in Excel 1

Status
Not open for further replies.

tdpeasb8

Technical User
Jan 22, 2003
4
0
0
US
This should be simple but I'm getting a type mismatch error and its driving me crazy.I have run code that selects specific rows:
Rows("2:51").Select
and it works just fine. I am trying to do the same with variables for the rows:
Rows("RValx:RValy").Select
Then I want to delete the rows.
Where I have declared the variables as integers or left them as varients. I can't get by the type mismatch error. I'm stumped
 
Change Rows("RValx:RValy") to Rows(RValx & ":" & RValy) and it should work fine

Rich
 
Try:

range(cells(rvalx,1),cells(rvaly,1)).entirerow.select

or, if you like playing with strings:

rows(rvalx & ":" & rvaly).select



Rob
[flowerface]
 
Thank you Rich and Rob,
For some reason I couldn't get the text version of the answer to work. It gave a compiler error and highlighted the ":" looking for a seperator.

The relative range did work. I would never have ever found the answer.

Thanks again!!!
 
For the first format to work, you need to make sure there is a space between "rvalx" and "&". Otherwise, the & operator gets interpreted as part of the variable name (a throwback to more ancient versions of basic).


Rob
[flowerface]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top