xxxxxxxxxx
Sub acitveCellInfo()
MsgBox "Active-column: " & ActiveCell.Column & ", Active-Row: " & ActiveCell.Row, vbInformation, "Active Cell"
End Sub
'if you want to see the column Nr's during working in Excel table you can change the reference-style
Sub changeReferenceStyle()
Application.ReferenceStyle = xlA1 + xlR1C1 - Application.ReferenceStyle
End Sub
xxxxxxxxxx
=COLUMN(A1)
The COLUMN function returns the column number of the given cell reference.
=COLUMN(D10) returns 4 because column D is the fourth column.
xxxxxxxxxx
def excel_column_number(column_name):
result = 0
for i in range(len(column_name)):
result *= 26
result += ord(column_name[i]) - ord('A') + 1
return result
# Example usage
column = 'AB'
column_number = excel_column_number(column)
print(f'The column number of {column} is {column_number}')
xxxxxxxxxx
excel get column numberexcel by Code Hero Code Hero on Jul 01 2022 Donate Comment
xxxxxxxxxx
Sub changeReferenceStyle()
Application.ReferenceStyle = xlA1 + xlR1C1 - Application.ReferenceStyle
End Sub