Need help on checkbox and textbox on userform

P

pswanie

1. i got 4 checkbox in a frame. when a user click commandbutton1 i need it
to check if checkbox1.value = true then print sheet1 if checkbox2.value =
true then print sheet2 etc through to checkbox4

2. when user click commandbutton2 i need it to check if textbox1.value =
"user2". if it does i need sheet6 unprotected. (is protected with password
"user1"). the value of textbox2 must be placed in cell (F33). sheet6
protected with password "user1".

thanx guys


Phillip
 
I

Incidental

Hi Philip

The code below is one way of doing it

Option Explicit
Dim i As Integer
Dim Ctrl As Control
Private Sub CommandButton1_Click()

For i = 1 To 4

Set Ctrl = UserForm1.Controls("CheckBox" & i)

If Ctrl.Value = True Then

Sheets(i).Activate

ActiveWindow.SelectedSheets.PrintOut _
Copies:=1, Collate:=True

End If

Set Ctrl = Nothing

Next i

End Sub

Private Sub CommandButton2_Click()

If TextBox1.Value = "user2" Then

With Sheets(6)

.Unprotect ("user1")
.Cells(33, 6).Value = TextBox2.Value
.Protect ("user1")

End With

End If

End Sub
 

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

Top