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!
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.

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
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,163,812
Messages
5,833,801
Members
430,233
Latest member
cbutts

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
Top