Hello
I have this code working on a form, it's working fine, simply writing the caption in the sheet if the box is checked...
I tried using variables, using loops and many other methods to get the same result without having to repeat the lines over and over but none worked
Private Sub OKButton1_Click()
Worksheets("Path").Activate
emptyRow = WorksheetFunction.CountA(Range("A:A")) + 1
Cells(emptyRow, 1).Select
If CheckBox1.Value = True Then
ActiveCell.Value = CheckBox1.Caption
ActiveCell.Offset(1, 0).Select
End If
If CheckBox2.Value = True Then
ActiveCell.Value = CheckBox2.Caption
ActiveCell.Offset(1, 0).Select
End If
If CheckBox3.Value = True Then
ActiveCell.Value = CheckBox3.Caption
ActiveCell.Offset(1, 0).Select
End If
If CheckBox4.Value = True Then
ActiveCell.Value = CheckBox4.Caption
ActiveCell.Offset(1, 0).Select
End If
If CheckBox5.Value = True Then
ActiveCell.Value = CheckBox5.Caption
ActiveCell.Offset(1, 0).Select
End If
Unload Me
End Sub
I have this code working on a form, it's working fine, simply writing the caption in the sheet if the box is checked...
I tried using variables, using loops and many other methods to get the same result without having to repeat the lines over and over but none worked
Private Sub OKButton1_Click()
Worksheets("Path").Activate
emptyRow = WorksheetFunction.CountA(Range("A:A")) + 1
Cells(emptyRow, 1).Select
If CheckBox1.Value = True Then
ActiveCell.Value = CheckBox1.Caption
ActiveCell.Offset(1, 0).Select
End If
If CheckBox2.Value = True Then
ActiveCell.Value = CheckBox2.Caption
ActiveCell.Offset(1, 0).Select
End If
If CheckBox3.Value = True Then
ActiveCell.Value = CheckBox3.Caption
ActiveCell.Offset(1, 0).Select
End If
If CheckBox4.Value = True Then
ActiveCell.Value = CheckBox4.Caption
ActiveCell.Offset(1, 0).Select
End If
If CheckBox5.Value = True Then
ActiveCell.Value = CheckBox5.Caption
ActiveCell.Offset(1, 0).Select
End If
Unload Me
End Sub