+ Reply to Thread
Results 1 to 5 of 5

how findout the calling cell address in a function

  1. #1
    Registered User
    Join Date
    01-24-2007
    Posts
    5

    how findout the calling cell address in a function

    hi,
    how do I know which cell called my userdefined function?. for example, I have a macro in a module and user used the function in several cells. when the user changes some value, the function is being called. Is there anyway I can find out which cell called the user defined function?. I need to do this programatically. please help. thanks

  2. #2
    Forum Contributor
    Join Date
    12-12-2005
    Posts
    667
    Maybe you want Activecell.Select?
    Best regards,

    Ray

  3. #3
    Registered User
    Join Date
    01-24-2007
    Posts
    5

    it won;t work

    i tried and Active cell won't work.

  4. #4
    Forum Contributor
    Join Date
    01-24-2007
    Location
    Southampton, UK
    Posts
    137
    Without knowing what the user defined function is exactly, a couple of suggestions are -

    (a) use the Worksheet_Change event to trap when a user makes a change anywhere in the worksheet. This event provides the cell address (Target) that was changed, which could be assigned to a global range variable and picked up by your function.

    Alternatively, use the Workbook_SheetSelectionChange event if the function is deployed on several Worksheets;

    (b) if your user-defined function is being activated by a change on the worksheet, then surely one of the parameters being passed to the function identifies the cell address? Alternatively, you could define your function to require the user to pass the range or cell details as a parameter wherever the function is used on the worksheet.

  5. #5
    Forum Contributor
    Join Date
    03-13-2005
    Posts
    6,195
    Quote Originally Posted by krish
    i tried and Active cell won't work.
    try

    =myfunc()


    Function myfunc()
    myfunc = ActiveCell.Address
    End Function


    hth
    ---
    Si fractum non sit, noli id reficere.

+ 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