VBA: how do I return a row number?

  • Thread starter Thread starter Mcasteel
  • Start date Start date
M

Mcasteel

How do I return a row number of an Excel workSheet to use in
formula?...


Then...

lets soppose I return row number 45. How do I select the columns
through 20 in row 45 (45 would need to be a variable that changes
 
Try this

Sub test()
Dim rnum As Long
rnum = 45
Range(Cells(rnum, 1), Cells(rnum, 20)).Select
End Sub
 
Hi Mcasteel,

If you want to be able to just type the SSN in a cell and have the macro
look it up and select the 20 columns, then this might help.

Sub SSN()
Dim i As Long
i = Range("F1").Value
Range("A" & i).Resize(1, 20).Select
End Sub

Or you could just change Ron's code to let rnum = a cell value, in this case
F1.

Sub test()
Dim rnum As Long
rnum = Range("F1").Value
Range(Cells(rnum, 1), Cells(rnum, 20)).Select
End Sub

HTH
Regards,
Howard
 

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

Back
Top