Public Variable

J

Jason

Can someone explain how to assign a public variable to my whole workbook so that it is recognized by all sheets
I want my password as a variable so that I don't have to change it in one place verses all of my sheets

Any help thanks in advance
 
J

Juan Pablo González

Jason said:
Can someone explain how to assign a public variable to my whole
workbook so that it is recognized by all sheets? I want my password
as a variable so that I don't have to change it in one place verses
all of my sheets.

Any help thanks in advance.

How are you storing it now ? because you could use a workbook name (possibly
hidden to add one layer of security), but if all you want is a public
variable, then put something like

Public ThePassword As String

at the top of one standard module.

You can define it as a constant, like

Public Const ThePassword As String = "123456"
 
H

Hotbird

Jason said:
Can someone explain how to assign a public variable to my whole workbook
so that it is recognized by all sheets?
I want my password as a variable so that I don't have to change it in one
place verses all of my sheets.
Try the following code at the top of your first module: The string variable
"Password" should be visible throughout your project.

OPTION EXPLICIT

Public strPassword as String
 
J

Jason

I have various input boxes on different sheets prompting for password. So on each sheet for each input box it is listed as
I basically want to change all my passwords at once with another input box, so that is why I need a public variable defined for all sheets or workbook. I think what you wrote will work for what I have. Not much security needed either

psw=Inputbox("Please Enter Password"
if psw = "MyPassword" the
my cod
end i


----- Juan Pablo González wrote: ----

Jason wrote
Can someone explain how to assign a public variable to my whol
workbook so that it is recognized by all sheets? I want my passwor
as a variable so that I don't have to change it in one place verse
all of my sheets

How are you storing it now ? because you could use a workbook name (possibl
hidden to add one layer of security), but if all you want is a publi
variable, then put something lik

Public ThePassword As Strin

at the top of one standard module

You can define it as a constant, lik

Public Const ThePassword As String = "123456
 
J

Jason

Thanks to all who responded. I am learning quite a bit about VBA, but little things I am still finding out.
 
Top