VBA Row(line) No Syntax?

  • Thread starter Thread starter Michael168
  • Start date Start date
M

Michael168

Can someone show the syntax in VBA for row no? I write a cell value from
sheet1 to a cell in sheet2. I would also like to write in the row no of
sheet1 in another cell of sheet2 so that I know where this value comes
from.

Thanks & Regards.
 
On Sat, 1 Nov 2003 00:19:44 -0500, Michael168

A range has a Row property that you can use for this:

Sub InsertRowNo()

Dim rng As Range

'One way...

Worksheets(2).Range("A1") = ActiveCell.Value
Worksheets(2).Range("B1") = ActiveCell.Row

'Using a variable range...

Set rng = ActiveCell

Worksheets(2).Range("A2") = ActiveCell.Value
Worksheets(2).Range("B2") = ActiveCell.Row

End Sub
 
Back
Top