Hey everyone,
I am having a bit of a problem with a userform. The goal is to allow the user to select which items he/she wants to divide the total contents of a cell to using checkboxes. i.e if the user selects two of the four checkboxes divide the cell by two and paste the values to the two appropriate cells. If the user selects three checkboxes, divide by three and paste to the three appropriate cells, etc. I have tried do this several ways so far and nothing is working. Here was my last fatal attempt:
Private Sub CommandButton1_Click()
Sheets("Instructions"
.Activate
Set cell1 = Worksheets("Instructions"
.Range("A39"
'if _
'one check box is chosen use this cell
Set cell2 = Worksheets("Instructions"
.Range("B39"
'this _
'cell is just A39 divided by two
Set cell3 = Worksheets("Instructions"
.Range("C39"
'by 3
Set cell4 = Worksheets("Instructions"
.Range("D39"
'by 4
Set P = Worksheets("Labor 1"
.Range("G15"
'cells represented
'by the checkboxes that if checked paste value here
Set PP = Worksheets("Labor 1"
.Range("G16"
Set PPP = Worksheets("Labor 1"
.Range("G17"
Set PPPP = Worksheets("Labor 1"
.Range("G18"
'if the first two checkboxes are clicked
If CheckBox1 = True + CheckBox2 = True _
+ CheckBox3 = False + CheckBox4 _
= False Then
cell2.Copy
P.PasteSpecial (xlPasteValues)
PP.PasteSpecial (xlPasteValues)
End If
End Sub
This is all suppose to be executed when you click OK
I know I have the wrong syntax somewhere, I just cannot see it right now. At first I was doing all of this with code, but thought it might be easier if I did the simple math right on the worksheet in hidden rows.
Thanks in advance for any help,
Brian
I am having a bit of a problem with a userform. The goal is to allow the user to select which items he/she wants to divide the total contents of a cell to using checkboxes. i.e if the user selects two of the four checkboxes divide the cell by two and paste the values to the two appropriate cells. If the user selects three checkboxes, divide by three and paste to the three appropriate cells, etc. I have tried do this several ways so far and nothing is working. Here was my last fatal attempt:
Private Sub CommandButton1_Click()
Sheets("Instructions"
Set cell1 = Worksheets("Instructions"
'one check box is chosen use this cell
Set cell2 = Worksheets("Instructions"
'cell is just A39 divided by two
Set cell3 = Worksheets("Instructions"
Set cell4 = Worksheets("Instructions"
Set P = Worksheets("Labor 1"
'by the checkboxes that if checked paste value here
Set PP = Worksheets("Labor 1"
Set PPP = Worksheets("Labor 1"
Set PPPP = Worksheets("Labor 1"
'if the first two checkboxes are clicked
If CheckBox1 = True + CheckBox2 = True _
+ CheckBox3 = False + CheckBox4 _
= False Then
cell2.Copy
P.PasteSpecial (xlPasteValues)
PP.PasteSpecial (xlPasteValues)
End If
End Sub
This is all suppose to be executed when you click OK
I know I have the wrong syntax somewhere, I just cannot see it right now. At first I was doing all of this with code, but thought it might be easier if I did the simple math right on the worksheet in hidden rows.
Thanks in advance for any help,
Brian