Return first column number in a range
This tutorial shows how to return the first column number from a selected range using an Excel formula or VBA
Example: Return first column number in a range
=COLUMN(B5:C10)
|
This formula uses the Excel COLUMN function to return the column number of the first cell in the selected range. In this example the first column in the range is column B which returns a value of 2, being the second column.
|
Sub Return_first_column_number_in_range()
'declare variables
Dim ws As Worksheet
Dim ws As Worksheet
Set ws = Worksheets("Analysis")
'return the first column number in a range
ws.Range("E5") = ws.Range("B5:C10").Column
ws.Range("E5") = ws.Range("B5:C10").Column
End Sub
EXPLANATION
This tutorial shows how to return the first column number from a selected range through the use of an Excel formula or VBA.
Using the COLUMN function in both the Excel and VBA methods it will return the first column number in a selected range.
FORMULA
=COLUMN(range)
=COLUMN(range)
ARGUMENTS
range: A range of cells for which you want to return the first column number.
range: A range of cells for which you want to return the first column number.
RELATED TOPICS
Related Topic | Description | Related Topic and Description |
---|---|---|
Return column number of a specific value | How to return a column number of a specific value using Excel and VBA | |
Return column name of a specific value | How to return a column name of a specific value using Excel and VBA | |
Return column name of a cell where the formula is written | How to return a column name of a cell where the formula is written using Excel and VBA | |
Return column name of a specific cell | How to return a column name of a specific cell using Excel and VBA |
RELATED FUNCTIONS
Related Functions | Description | Related Functions and Description |
---|---|---|
COLUMN Function | The Excel COLUMN function returns the first column number of the selected reference |