ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Determine Column Number in a function (https://www.excelbanter.com/excel-programming/394905-determine-column-number-function.html)

cubbybear3

Determine Column Number in a function
 
I have a function that needs to know the column number/letter of the
cell calling it. How does a novice like myself do this? Thanks. -
pb


Bob Umlas

Determine Column Number in a function
 
Function ColNum() As Integer
ColNum = Application.Caller.Column
End Function

Just enter =ColNum() in a cell.
However, =COLUMN() does that already!

"cubbybear3" wrote in message
ups.com...
I have a function that needs to know the column number/letter of the
cell calling it. How does a novice like myself do this? Thanks. -
pb




Ronald Dodge[_2_]

Determine Column Number in a function
 
Here's an example of the Caller Property you would use on the application
within the custom function.

Dim v as StringSelect Case TypeName(Application.Caller)
Case "Range"
v = CStr(Application.Caller.Column)
Case Else
v = "unknown"
End Select
MsgBox "Column number calling this function is " & v & "."-- Sincerely,
Ronald R. Dodge, Jr.
Master MOUS 2000

"cubbybear3" wrote in message
ups.com...
I have a function that needs to know the column number/letter of the
cell calling it. How does a novice like myself do this? Thanks. -
pb





All times are GMT +1. The time now is 12:01 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com