PC Review


Reply
Thread Tools Rate Thread

Calculation Context available inside an Excel VBA function?

 
 
David Boden
Guest
Posts: n/a
 
      11th Apr 2008
Our Excel VBA Add-In hits our server one or more times every time the user
hits F9 to recalculate their values. Sometimes, the users who have written
the spreadsheets have organised things in such a way that the function is
called 5 or more times which results in 5 or more calls to our server. The
users won't tolerate a timeout or delay in getting data into their
spreadsheet when they hit F9 and they need up-to-the-second data so the
server must be hit each time F9 is pressed, but we need to avoid making 5
unnecessary server calls.

Inside the VBA function we *need* to be able to work out the context in
which the function is being called. At an absolute minimum, we should be able
to query a unique ID for the user event that caused the recalculate, be that
either an F9 keypress or the change of a cell's value. The cascading changes
should all be part of an identifiable transaction. More information about the
transaction would be great, specifically whether it was an F9 or an autocalc
that caused the transaction.

We could then cache the server values only for the life of the calculation
transaction. This would allow users to get up-to-the-second data, but would
allow the Excel Add-In to be smart and not make 5 server calls.

At its most basic this would be Application.getCalculationID() that could be
called within a function.

Is there a way of getting this information inside a VBA function in any
Office version? This is a real-world problem in an investment bank.
 
Reply With Quote
 
 
 
 
Charles Williams
Guest
Posts: n/a
 
      11th Apr 2008
David,

Some information about the calculation is available inside a function, but
not exactly as you have specified, also there are many more things that can
cause a recalc than F9 or a change in Automatic.

You should make sure your function is not being called multiple times
because of uncalculated cells or the function wizard.
(see http://www.DecisionModels.com/calcsecretsj.htm)

Then if there are multiple instances of the function being called per
calculation event you could set a switch from the first execution of the
function so that subsequent executions of the function would know to get the
cached value, and the reset the switch in a Calculate event (which fires
after the calculation).
If neccessary you could have separate cached values each with its own
identifier.

regards
Charles
__________________________
The Excel Calculation Site
http://www.decisionmodels.com

"David Boden" <(E-Mail Removed)> wrote in message
news:2432DF11-865B-4CAA-A1CC-(E-Mail Removed)...
> Our Excel VBA Add-In hits our server one or more times every time the user
> hits F9 to recalculate their values. Sometimes, the users who have written
> the spreadsheets have organised things in such a way that the function is
> called 5 or more times which results in 5 or more calls to our server. The
> users won't tolerate a timeout or delay in getting data into their
> spreadsheet when they hit F9 and they need up-to-the-second data so the
> server must be hit each time F9 is pressed, but we need to avoid making 5
> unnecessary server calls.
>
> Inside the VBA function we *need* to be able to work out the context in
> which the function is being called. At an absolute minimum, we should be
> able
> to query a unique ID for the user event that caused the recalculate, be
> that
> either an F9 keypress or the change of a cell's value. The cascading
> changes
> should all be part of an identifiable transaction. More information about
> the
> transaction would be great, specifically whether it was an F9 or an
> autocalc
> that caused the transaction.
>
> We could then cache the server values only for the life of the calculation
> transaction. This would allow users to get up-to-the-second data, but
> would
> allow the Excel Add-In to be smart and not make 5 server calls.
>
> At its most basic this would be Application.getCalculationID() that could
> be
> called within a function.
>
> Is there a way of getting this information inside a VBA function in any
> Office version? This is a real-world problem in an investment bank.



 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Using SQL (with a Group by function) inside EXCEL VBA Alpha09 Microsoft Excel Programming 1 13th Nov 2009 02:13 AM
Excel Function inside FOR loop. jalves428@gmail.com Microsoft Excel Programming 2 30th Jan 2009 10:46 PM
Launching context-sensitive HTML Help for a Function in Excel Add-In kwong.joey@gmail.com Microsoft Excel Programming 2 21st Jul 2006 01:06 AM
Using a range variable inside a excel function =?Utf-8?B?TWljaGFlbA==?= Microsoft Excel Misc 2 14th Nov 2005 02:52 PM
Excel Function/Formula help...Variable inside a SumIf ? tj832006 Microsoft Excel Worksheet Functions 2 1st Mar 2004 06:42 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:58 AM.