Varible in a Range

  • Thread starter Thread starter mushy_peas
  • Start date Start date
M

mushy_peas

Is there a way to specify a range based on a varible, for example


Range("Asomenumber").Select

eg. where somenumber = 5, so that A5 in this case is selcted, but i
somenumber changed then another cell selected
 
As far as I know, the only way to create ranges based on
variables is by using the Cells collection.

For example:

myWS.Cells(myRow, myCol).Select

myWS - Worksheet Object
myRow - an Int or Long ( 32768 limitation on some systems)
myCol - Int
 
mushy_peas < said:
Is there a way to specify a range based on a varible, for example


Range("Asomenumber").Select

eg. where somenumber = 5, so that A5 in this case is selcted, but if
somenumber changed then another cell selected.

SomeNumber = 5
Range("A" & SomeNumber).Select

Will get you to A5.

Regards,
 
I tried the myWS method cos i wanted to specify the colume too. but i
coulndt get it to work. one thing i spottte was:-

(myRow, myCol).

normally its colum then row, eg B10

any ideas why. this is what i have
Dim myWS As Object
Dim myRow As Integer
Dim myCol As Integer
myRow = 10
myCol = 2

' myWS.Cells(myCol, myRow).Select
myWS.Cells(myRow, myCol).Select
 
Back
Top