macro syntax for selecting variable range

  • Thread starter Thread starter Matt
  • Start date Start date
M

Matt

In a VBA script

Sub SelectCells()
X=3
Range("A1:A" & X).Select
EndSub

would do the same as

Sub SelectCells()
Range("A1:A3").Select
EndSub


I'm wondering is it possible to do something like this?

Sub SelectCells()
X=3
Y=4
'??? Range("A"&X":A" & Y).Select???
EndSub

so that it gives the same as

Sub SelectCells()
X=3
Y=4
'Range("A3:A4").Select
EndSub

Matt
 
Sub SelectCells()
Dim X, Y As Integer
X = 3
Y = 4
Range("A" & X & ":A" & Y).Select
End Sub


Gord Dibben MS Excel MVP
 
Back
Top