How to get address of cell which calls a VBA Functions in a Excel sheet

后端 未结 1 1309
温柔的废话
温柔的废话 2020-12-05 18:44

Is there a function to get the address of a cell which call a VBA function ?

I used \"Application.ActiveCell.Address\" , but found that this method is not a correct

相关标签:
1条回答
  • 2020-12-05 19:10

    You can use Application.Caller, but you would probably be best to pass the cell to the function.

       With Application.Caller
            CallerRows = .Rows.Count
            CallerCols = .Columns.Count
            CallerAddr = .Address
       End With
    

    See: http://www.cpearson.com/excel/WritingFunctionsInVBA.aspx

    To pass the cell:

     =SomeFunction(A1)
    

    Where the code has:

    SomeFunction(r)
    
    0 讨论(0)
提交回复
热议问题