rows select using macro

  • Thread starter Thread starter Just Merks
  • Start date Start date
J

Just Merks

Hello,

Can someone assist. I'm fiddling around with some basic VBS programming.

When I want to select multiple rows (i.e 3-9) from an sheet I can use

Rows(" 3 , 9 ").select

However what should I do when one of those argument is a variable.

I.E.
varrow = 9
rows("3, varrow").select

This does not do the trick??
 
Joe,

Startrow = 3
NumRows = 6

' One way:
Cells(Startrow, 1).Resize(NumRows, 1).EntireRow.Select

'Another:
Range(Cells(Startrow, 1), Cells(Startrow + NumRows - 1, 1)).EntireRow.Select

--
Earl Kiosterud
www.smokeylake.com

Note: Top-posting has been the norm here.
Some folks prefer bottom-posting.
But if you bottom-post to a reply that's
already top-posted, the thread gets messy.
When in Rome...
 
This will select row 33 but I suspect that is not what you want

Sub selectVariableRows()
myrow = 3
Rows("3," & myrow).Select
End Sub
 
Back
Top