VBA Constant

edvwvw

Active Member
Joined
Jan 30, 2007
Messages
278
Is there any way that I can change a constant in VBA

Option Explicit
Const MaxAccuracy = 0.00001
Const MaxLoops = 100
Constant Reset = 900

I want to be able to change the Reset constant to 900 or 3600.

The variable is called over 20 times within the code so if possible I would rather use the Option Explicit rather than make all of the entries using Public Function for each area of the module.

Any help would be greatly appreciated - thanks

edvwvw
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
If you have a value that you want to change throughout the code, why don’t you just declare it as a variable rather than a constant?

FYI – Option Explicit just forces all variables and constants to be declared. It has no bearing on where or how they are defined.
 
Upvote 0
I think what the person in question was looking for was:

replace
Const variable_name = some_value

with
Public variable_name as variable_type

and then give it a value in the code.
this way all functions and subs have access to it.
 
Upvote 0

Forum statistics

Threads
1,214,593
Messages
6,120,435
Members
448,961
Latest member
nzskater

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