Input Box

Nomis_Eswod

Board Regular
Joined
Jul 27, 2005
Messages
153
Hi,

I have a form that shows when I open my spreadsheet.

In this form is a textbox where the user has to enter their name.

The below code outlines what I already have

What I want to do is put something into the Initialise code of another form
Code:
Dim Name
Name = TextBox1.Value
Unload Me
If Password = "Name1" Then
Sheets("ControlSheet").Visible = True
Sheets("ENTER PASSWORD").Visible = False
Else
If Password = "Name2" Then
Sheets("ControlSheet").Visible = True
Sheets("ENTER").Visible = False
Else
MsgBox "That is not a valid name.  Please ensure you do not have CAPS LOCK on because names are case sensitive" & vbCrLf & vbCrLf & _
"Please re-enter your name", vbCritical + vbOKOnly, "Error"
entry.Show
End If
End If

End Sub
so that if Name declared in the above code equals Name1 to call another macro.

So in the other form I have:

Code:
If Name = "Name1" Then 

Call ReadOnly

End If

But it doesn't seem to recognise the Name...any ideas?

ThAnKs in advance!
 

Some videos you may like

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK

BrianB

Well-known Member
Joined
Feb 17, 2003
Messages
8,127
To share variables they have to be declared top of a module before any code. Not sure about the overall structure you have, so the safest way would be to declare the variable as Public so it can be accessed by other modules. Take care the variable is not declared anywhere else.

'Name' is a "Reserved Word" ie. VBA uses it. It is a bad idea to use these yourself. You might get away with it for a time but the macro could "inexplicably" fail later on. So .....

Code:
Public MyName As String
 

Watch MrExcel Video

Forum statistics

Threads
1,118,540
Messages
5,572,791
Members
412,484
Latest member
deezina07
Top