Return row number of an active cell

To return a row number of an active cell we need to use an ActiveCell.Row function in VBA

METHOD 1. Return row number of an active cell using VBA

VBA

Sub Return_row_number_of_an_active_cell()
'declare a variable
Dim ws As Worksheet
Set ws = Worksheets("Analysis")

'get row number of an active cell and insert the value into cell A1
ws.Range("A1") = ActiveCell.Row

End Sub

OBJECTS
Worksheets: The Worksheets object represents all of the worksheets in a workbook, excluding chart sheets.
Range: The Range object is a representation of a single cell or a range of cells in a worksheet.
PREREQUISITES
Worksheet Name: Have a worksheet named Analysis.

ADJUSTABLE PARAMETERS
Output Range: Select the output range by changing the cell reference ("A1") in the VBA code to any cell in the worksheet, that doesn't conflict with formula.

Explanation about how to return row number of an active cell

EXPLANATION

EXPLANATION
To return a row number of an active cell we can apply an ActiveCell.Row function in VBA. In this example we are returning the row number into cell A1 in a worksheet named Analysis. Therefore, when the VBA code is run it will return the row number in the specific location.