View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_4_] Bob Phillips[_4_] is offline
external usenet poster
 
Posts: 834
Default Run a sub every time a function is used in a sheet

We both assumed that you have a custom worksheet function (UDF), and so you
would add our suggestion into there.

It won't work with a built-in function.

--

HTH

Bob

"Subodh" wrote in message
...
On May 6, 2:09 pm, Jacob Skaria
wrote:
You can check whether the function is called from the activecell.....

Function GetSomething(strData As String)

'your code

If Application.Caller.Address = ActiveCell.Address Then
'function called from the activecell...
'do something
End If

End Function

--
Jacob (MVP - Excel)



"Subodh" wrote:
I have a custom function in Excel
I want to run other sub lets say to display a msg box each time the
function
is used in the sheet (not each time the function is calculated)
ie. only at the time the function is used in the sheet.
lets say in coding i want the following


Function myfunction (x as variant) as variant
myfunction = x+x
end function


sub mysub ()
'this should run each time the function
'my function is used in the cell
'not each time the function is calculated
msgbox "Myfunction is used in the active cell"
end sub
.- Hide quoted text -


- Show quoted text -


@ Bob
@ Jacob
Sorry I could not find out where to put the above code
either in the sheet or in the module
I tried both but it didn't worked.
I think i missed something.
Also, i couldn't determine which or how to define the range
Or, does it works for all the range
As desired, it is expected that it should work on every cells of the
workbook
Thanks for the prompt response.