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

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
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
 
Upvote 0

Forum statistics

Threads
1,214,952
Messages
6,122,457
Members
449,083
Latest member
Ava19

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