Global variable for add-in?

paipimenta

Board Regular
Joined
Apr 7, 2010
Messages
103
I'm working on an add-in that will have a user-form to make changes to a complex workbook. The add-in changes workbook "Audit Form.xls". How can I set this file name as a global constant in my add-in, so that I can just change this file name once in the add-in?

I'm looking for something like this....
Code:
Public Contant auditFileName As String
auditFileName = "Audit Form.xls"
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
Hi,

At the top of one of your modules house something like;

Code:
Public StrFileName as string

although I'd suggest writing the value to a name as if you have a single unhandled error within the code then and variables will be lost. If you write it to a name you can always refer to it as such;

Code:
ThisWorkbook.Range("MyFileName")
 
Upvote 0
If you want a constant in your code:
Code:
Public Const auditFileName As String = "Audit Form.xls"
 
Upvote 0

Forum statistics

Threads
1,214,943
Messages
6,122,380
Members
449,080
Latest member
Armadillos

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