+ Reply to Thread
Results 1 to 3 of 3

Determine the current cell while inside a User Defined Function

  1. #1
    pmax
    Guest

    Determine the current cell while inside a User Defined Function

    I have a worksheet that contains User Defined Function calls in the
    cells. At the time you open the sheet, the function is called and
    populates the value for the cell. I am trying to determine the current
    cell. When I walk through this in debug mode, it says the active column
    is the last column that was active when the sheet was saved. It doesn't
    refer to the current cell that has called the user defined function.
    How can I determine what the cell that the user defined function is
    currently updating?

    My cell contains the following function:
    =wbGetLastCompletedSampleDate("123","abc",QueryDates!B8,QueryDates!B9)
    When it runs the function, I need to set 2 custom document properties
    for the cell that contain QueryDates!B8 & QeuryDates!B9. Whenever I
    look at the activecell within the function WbGetLastCompletedSampleDate
    (in runtime) it always returns the same value.

    I appreciate any feedback on this issue.

    Thanks.


  2. #2
    Dave Peterson
    Guest

    Re: Determine the current cell while inside a User Defined Function

    Application.caller
    is what you're looking for.

    Option Explicit
    Function myFunc() As String
    With Application.Caller
    myFunc = .Row & "--" & .Column
    End With
    End Function

    pmax wrote:
    >
    > I have a worksheet that contains User Defined Function calls in the
    > cells. At the time you open the sheet, the function is called and
    > populates the value for the cell. I am trying to determine the current
    > cell. When I walk through this in debug mode, it says the active column
    > is the last column that was active when the sheet was saved. It doesn't
    > refer to the current cell that has called the user defined function.
    > How can I determine what the cell that the user defined function is
    > currently updating?
    >
    > My cell contains the following function:
    > =wbGetLastCompletedSampleDate("123","abc",QueryDates!B8,QueryDates!B9)
    > When it runs the function, I need to set 2 custom document properties
    > for the cell that contain QueryDates!B8 & QeuryDates!B9. Whenever I
    > look at the activecell within the function WbGetLastCompletedSampleDate
    > (in runtime) it always returns the same value.
    >
    > I appreciate any feedback on this issue.
    >
    > Thanks.


    --

    Dave Peterson

  3. #3
    pmax
    Guest

    Re: Determine the current cell while inside a User Defined Function

    Thank YOU! I searched help and looked at my books, but didn't find
    that. I appreciate your help.


+ 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