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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I use variable row numbers for Row("14:16").Select

Status
Not open for further replies.

stevenwang78

Technical User
Apr 2, 2004
1
CA
Hi,

I want to use variables to replace the specific numbers in selecting a range, e.g.

I = 15
J = 20
' How to define the rows from 15 to 20?

Thanks,

Steven
 
Steven,

All kinds of ways to skin a cat.
Code:
i=15
j=20
c=1
'Cells(row, col) is syntax - I prefer this one
With Range(Cells(i, c), Cells(j, c)).entirerow
   'do stuff to this range

end with
[code]
or
[code]
i=15
j=20
With Rows(i & ":" & j)
   'do stuff to this range

End with

:)

Skip,

Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 

I would go for:

with range(rows(i),rows(j))


no concatenating strings and less dots therefore faster.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top