Userform Macro

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have the following macro that I am trying to adapt to work with my user
form. The user form is to prompt for a password to run a macro that unhides
a range of cells. I have not a clue what I am doing, but I am trying. Any
help would be greatly appreciated.

Sub Button1_Click()
If TextBox1.Text <> "1234" Then
MsgBox "Invalid password - you cannot access this"
UnHide.Hide
Exit Sub
Else
Range("E17:E50").Select
Selection.Font.ColorIndex = 0
Range("E17").Select
ActiveSheet.Range("A1").Select

End If
End Sub

Thanks
Mike Rogers
 
Mike,

Assuming you are talking about a "UserForm" and not something
you have created on a spreadsheet then this ought to get you started...
'-------------------
Private Sub CommandButton1_Click()
If TextBox1.Text <> "1234" Then
MsgBox "Invalid password ", vbExclamation, "Contact Mike Rogers"
Else
With Rows("17:50")
.Hidden = False
.Font.ColorIndex = 0
End With
Range("A1").Select
End If
Me.Hide
Unload Me
End Sub
'-----------------
Regards,
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware


I have the following macro that I am trying to adapt to work with my user
form. The user form is to prompt for a password to run a macro that unhides
a range of cells. I have not a clue what I am doing, but I am trying. Any
help would be greatly appreciated.

Sub Button1_Click()
If TextBox1.Text <> "1234" Then
MsgBox "Invalid password - you cannot access this"
UnHide.Hide
Exit Sub
Else
Range("E17:E50").Select
Selection.Font.ColorIndex = 0
Range("E17").Select
ActiveSheet.Range("A1").Select

End If
End Sub

Thanks
Mike Rogers
 
Jim,

Yes, It was a real "Userform", as opposed to a form that I made for others
to use. Thank you for getting me straightened out. Now I can study what
works (yours), and what does not work (mine), and see if I can understand how
I messed it up. Thanks for the response it was precisely what needed.

Mike Rogers
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top