Application.Volatile.. When to use, When not to use

mtheriault2000

Well-known Member
Joined
Oct 23, 2008
Messages
826
Hello

I have seen in a code, application.volatile = True and I'm not sure whether or not it apply to my need
Code:
Public Function Call_GetNamedString() As String
   Dim String_i As String
   Application.Volatile True
   String_i = GV_GetNamedString("DataString", "error")
   Call_GetNamedString = String_i
    Application.Volatile True
End Function

Anyone could give me another explanation than the one in the Help from Excel. I just don't catch it

Martin
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
Hi Martin

The Application.Volatile makes the code of the udf to be executed everytime the worksheet recalculates and so you should always avoid it if you can.

The good practice is to define the function with the inputs that should trigger the recalculation.

In your case you have no parameters in your udf which is not usual. What are you trying to do? What are the inputs that should trigger the recalculation?
 
Upvote 0
Hello PGC01

The function is use in the context of communication between Excel and an external software. Some info are exchange between them using a Global Variable concept. Excel and the other software (Multicharts), use the same named Global Variables to exchange information.

Since external data may come in in any moment, I want to be able to read and update my sheet accordingly to the new data.

With your little explanation, i understand a bit more now.

Martin
 
Upvote 0

Forum statistics

Threads
1,224,520
Messages
6,179,267
Members
452,902
Latest member
Knuddeluff

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top