Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Calling Cell (or ROW() and COLUMN() in VBA)
I am new to VBA and need what I would think would be something easy, but I
have not been able to work out how to do it. I have a macro that sums all values from the cell the macro is in to some limit. At present I need to enter "=ITEMSUM(ROW(),COLUMN())" in the cell. So I know where I am being called from. What I want to be able to enter in the cell is "=ITEMSUM()" and inside ItemSum get the equivalent of ROW() and COLUMN(). How can I do this? |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Calling Cell (or ROW() and COLUMN() in VBA)
I think this is what you are looking for.
Public Function Whatever() As String 'Application.volatile 'if you need it to recalc no matter what changes With Application.Caller Whatever = "Row " & .Row & " and column " & .Column End With End Function insert this in a standard code module and call it from a cell. It will return the row and column of the cell that it is in... -- HTH... Jim Thomlinson "Scott" wrote: I am new to VBA and need what I would think would be something easy, but I have not been able to work out how to do it. I have a macro that sums all values from the cell the macro is in to some limit. At present I need to enter "=ITEMSUM(ROW(),COLUMN())" in the cell. So I know where I am being called from. What I want to be able to enter in the cell is "=ITEMSUM()" and inside ItemSum get the equivalent of ROW() and COLUMN(). How can I do this? |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Calling Cell (or ROW() and COLUMN() in VBA)
Thanks Jim. Application.Caller was exactly the thing I was hunting for
"Jim Thomlinson" wrote: I think this is what you are looking for. Public Function Whatever() As String 'Application.volatile 'if you need it to recalc no matter what changes With Application.Caller Whatever = "Row " & .Row & " and column " & .Column End With End Function insert this in a standard code module and call it from a cell. It will return the row and column of the cell that it is in... -- HTH... Jim Thomlinson "Scott" wrote: I am new to VBA and need what I would think would be something easy, but I have not been able to work out how to do it. I have a macro that sums all values from the cell the macro is in to some limit. At present I need to enter "=ITEMSUM(ROW(),COLUMN())" in the cell. So I know where I am being called from. What I want to be able to enter in the cell is "=ITEMSUM()" and inside ItemSum get the equivalent of ROW() and COLUMN(). How can I do this? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Calling Column D | Excel Discussion (Misc queries) | |||
Calling Column D | Excel Discussion (Misc queries) | |||
Calling Column D | Excel Discussion (Misc queries) | |||
Calling Column D | Excel Discussion (Misc queries) | |||
Calling Column D | Excel Discussion (Misc queries) |