MACRO problem!!

%3CLINGO-SUB%20id%3D%22lingo-sub-1686733%22%20slang%3D%22en-US%22%3EMACRO%20problem!!%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1686733%22%20slang%3D%22en-US%22%3E%3CP%3EI%20am%20using%20MACRO%20in%20Excel.%26nbsp%3B%3C%2FP%3E%3CP%3EIn%20the%20syntax%2C%26nbsp%3BRows(%3CFONT%20color%3D%22%23FF0000%22%3E%223%3A3%22%3C%2FFONT%3E).Select%2C%20Can%20I%20replace%20%223%3A3%22%26nbsp%3Bwith%20a%20formula%3F%3C%2FP%3E%3CP%3EPlease%20help!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1686733%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1686817%22%20slang%3D%22en-US%22%3ERe%3A%20MACRO%20problem!!%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1686817%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F799535%22%20target%3D%22_blank%22%3E%40michaelho666%3C%2FA%3E%26nbsp%3BCreate%20a%20variable%20that%20holds%20the%20row%20number%20you%20want%20to%20select%2C%20e.g.%20%22RowToSelect%22.%20Then%20use%20this%20code%20in%20VBA%3A%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-visual%22%3E%3CCODE%3ERows(RowToSelect%20%26amp%3B%20%22%3A%22%20%26amp%3B%20RowToSelect).Select%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
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
Highlighted

@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

 

Highlighted

@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")
SLROW.Select

End Sub