How to refer to cells with a variable ?

  • Thread starter Thread starter Blewyn
  • Start date Start date
B

Blewyn

I would like to refer to a range of cells using a variable, as in :

Range "A1:A(RowNumber)"

where rownumber is a variable. The basic code above does not work, an
I can't find any advice in the help files.

Is there a way to do this ?

Thanks,

Blewy
 
Sub test()

Dim row1 As Integer
Dim row2 As Integer
Dim col1 As Integer
Dim col2 As Integer

row1 = 2
row2 = 10
col1 = 3
col2 = 6

Range(Cells(row1, col1), Cells(row2, col2)).Select

End Sub


RBS
 
One way:

Range("A1:A" & RowNumber).Interior.ColorIndex = 3

where RowNumber is a Long.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top