Return column number of an active cell

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

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

VBA

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

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

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 column number of an active cell

EXPLANATION

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