MACRO problem!!

Occasional Visitor

I am using MACRO in Excel. 

In the syntax, Rows("3:3").Select, Can I replace "3:3" with a formula?

Please help!

2 Replies

@michaelho666 Create a variable that holds the row number you want to select, e.g. "RowToSelect". Then use this code in VBA:

Rows(RowToSelect & ":" & RowToSelect).Select


@michaelho666 ,,,


This is the best and easiest method you can use.





Dim X As String, Y As String
X = 7
Y = 11
Rows(X & ":" & Y).Select




or to select multiple rows you may use this one.




Sub testRowselect()

Dim SLROW As Range
Set SLROW = Range("A1:A20")

End Sub