I have several named columns on a sheet. I want to send the column number to a function that will return the column name.
For example, if column 1 is named "apple", I want to pass the column number 1 to a function that returns the column name "apple". My attempt:
Function getColName(colNumber As Integer) As String
'return column name when passed column number
getColName = Cells(1, colNumber).Column.Name
End Function
How can I get this code to work?
getColName = Cells(1, colNumber).Value
– EquipotentialgetColName = Cells(1, colNumber).EntireColumn.Name.Name
– Oliveolivegreen