PDA

View Full Version : Sleeper: Is UDF called from Wizard ?



macleanb
02-04-2010, 03:51 AM
Hi Guys

Have to admit I have cross posted this from Mr Excel - I am hoping this is more "up your Strasse" - as the only reply I got on Mr Excel was not very helpful.

I have a series of VBA UDF's that are reasonably long running - and I dont want them to perform their normal calcs when called from the Function Wizard dialog.

My basic question is - how can I tell if the VBA UDF has been called from the wizard (without resorting to a C++ based addin)


ttfn benm

lucas
02-04-2010, 07:51 AM
Please read this (http://www.excelguru.ca/node/7)

macleanb
02-04-2010, 07:57 AM
Frustratingly off topic (and I thought you were a uber-coder with a slick solution) - If you read the page you so thoughtfully provided it says:

"you've cross posted somewhere, not told us, and been busted"

Which clearly doesnt apply to my post!

I wouldnt have bothered to point this out - except I'm recovering from the emotional let down of you not posting a solution to thjis knarly issue - which has made me a touch grouchy!

lucas
02-04-2010, 08:05 AM
That's because it's off topic for you. Not me. I'm not here to impress and all I'm asking you to do is be courtious.

If you had read the whole thing you would have read this line:



Include a link to your original post (see below).


It even gives detailed explainations of how to do that for those who do not understand.

I'm not going to go into detail as to why it is just simple common courtesy to do this as the link I provided spells it out for you. You did say you read it didn't you?

Jan Karel Pieterse
02-04-2010, 08:05 AM
What you could do is redirect the formula wizard to a small macro, like this:


Option Explicit
Public gbCalculating As Boolean
Public Function TEST(oRng As Range)
On Error Resume Next
If gbCalculating = False Then
TEST = "NA"
Debug.Print "FW"
Else
TEST = oRng.Value ^ 2
Debug.Print "Cell"
End If
End Function
Public Sub ShowFormulaWiz()
gbCalculating = False
Application.CommandBars("worksheet menu bar").FindControl(ID:=385, recursive:=True).Execute
gbCalculating = True
End Sub

Run the sub ShowFormulaWiz to see what I mean.
After running ShowFormulaWiz, the cells aren't recalced though, so you need to add a activesheet.calculate after the gbCalculating=True statement.

macleanb
02-04-2010, 08:09 AM
Thanks for the idea - dont think its really a flyer as this sheet needs to be distributable, and I dont think I can subvert all the users to do this. But thanks anyway....

lucas
02-04-2010, 08:26 AM
Thread locked for refusal to provide link to cross post.