+ Reply to Thread
Results 1 to 3 of 3

From which cell is my VBA function called ?

  1. #1
    Helge V. Larsen
    Guest

    From which cell is my VBA function called ?

    I have a VBA function that is called from many cells in several worksheets
    in my workbook. The function performs some error trapping (data checking)
    and gives a message if an error is found.

    However, I need to retrieve information on from where the erroneous call of
    the function is placed (sheet and cell).

    Is it possible to get this information by VBA ?



  2. #2
    Niek Otten
    Guest

    Re: From which cell is my VBA function called ?

    Application.Caller.Address

    --
    Kind regards,

    Niek Otten
    Microsoft MVP - Excel

    "Helge V. Larsen" <Helge.V.Larsen_Remove_this@Risoe_Remove_this.DK> wrote in message
    news:%23MUc5MGwGHA.2432@TK2MSFTNGP06.phx.gbl...
    |I have a VBA function that is called from many cells in several worksheets
    | in my workbook. The function performs some error trapping (data checking)
    | and gives a message if an error is found.
    |
    | However, I need to retrieve information on from where the erroneous call of
    | the function is placed (sheet and cell).
    |
    | Is it possible to get this information by VBA ?
    |
    |



  3. #3
    Dana DeLouis
    Guest

    Re: From which cell is my VBA function called ?

    > However, I need to retrieve information on from where the erroneous
    call of
    > the function is placed (sheet and cell).



    Would the "Caller" property work?

    Function MyFunction(x)
    If TypeName(Application.Caller) = "Range" Then
    Debug.Print Application.Caller.Address(External:=True)
    'or maybe
    Debug.Print Application.Caller.Address(False, False, , True)
    End If
    MyFunction = x * x
    End Function

    HTH
    Dana DeLouis


    Helge V. Larsen wrote:
    > I have a VBA function that is called from many cells in several worksheets
    > in my workbook. The function performs some error trapping (data checking)
    > and gives a message if an error is found.
    >
    > However, I need to retrieve information on from where the erroneous call of
    > the function is placed (sheet and cell).
    >
    > Is it possible to get this information by VBA ?
    >
    >


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1