Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
how to make sure which worksheet call the function
I have a function in the Sheet1, and I also call this function from
Sheet2. There are many msgbox in this function which I only want them to execute when called by Sheet1. That is, when the function is called by Sheet2, I don't want any msgbox shown. The problem is how I can get to know which sheet is calling. Thanks! |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
how to make sure which worksheet call the function
I would think that msgbox's in UDF's would soon get irritating to the user, but
this kind of thing works ok for me: Option Explicit Function myFunc() If LCase(Application.Caller.Parent.Name) = LCase("sheet1") Then MsgBox "hi there" End If myFunc = "bye there!" End Function "lvcha.gouqizi" wrote: I have a function in the Sheet1, and I also call this function from Sheet2. There are many msgbox in this function which I only want them to execute when called by Sheet1. That is, when the function is called by Sheet2, I don't want any msgbox shown. The problem is how I can get to know which sheet is calling. Thanks! -- Dave Peterson |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
how to make sure which worksheet call the function
Thanks. It works. But when I call from a module, it doesn't work again.
Any idea? |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
how to make sure which worksheet call the function
maybe...
Option Explicit Function myFunc() If TypeName(Application.Caller) = "Range" Then If LCase(Application.Caller.Parent.Name) = LCase("sheet1") Then MsgBox "hi there" End If End If myFunc = "bye there!" End Function "lvcha.gouqizi" wrote: Thanks. It works. But when I call from a module, it doesn't work again. Any idea? -- Dave Peterson |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
how to make sure which worksheet call the function
Thank you very much! It works now.
|
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How to call a worksheet (as a function) | Excel Discussion (Misc queries) | |||
NEED TO MAKE THE PRINT BUTTON FUNCTION IN WORKSHEET | Excel Worksheet Functions | |||
How to make a function change other cells in worksheet | Excel Programming | |||
how can i make grafs for role call? | Excel Discussion (Misc queries) | |||
can I call a worksheet function from within vba? | Excel Programming |