Hi, I have a userform that pops up when you enter a specific cell. The userform has 6 Checkboxs on it named checkbox1, checkbox2 etc and 1 textbox. The captions for the checkboxes are the names in cells B1-B5 and and a 6th named "Other". These checkboxes are only visible when there is a name in the corresponding cell. What I need to do is fill Cell F5 with the names that are selected from the checkboxes seperated by a comma, but I can't get the code right if there is only one selection made.
Here is the data:
This is the code I have so far, It works but puts a comma in front of the text if only 1 option has been selected:
Here is a copy of the userform also:
Here is the data:
Book1 | ||||||
---|---|---|---|---|---|---|
A | B | C | D | |||
1 | ProjectManager | Bob | ||||
2 | ProjectTeam | Test | ||||
3 | Test2 | |||||
4 | ||||||
5 | ||||||
Sheet1 |
This is the code I have so far, It works but puts a comma in front of the text if only 1 option has been selected:
Code:
Private Sub CommandButton1_Click()
If UserForm10.CheckBox1.Value = True Then
ActiveCell.Value = ActiveCell.Value + ", " + UserForm10.CheckBox1.Caption
End If
If UserForm10.CheckBox2.Value = True Then
ActiveCell.Value = ActiveCell.Value + ", " + UserForm10.CheckBox2.Caption
End If
If UserForm10.CheckBox3.Value = True Then
ActiveCell.Value = ActiveCell.Value + ", " + UserForm10.CheckBox3.Caption
End If
If UserForm10.CheckBox4.Value = True Then
ActiveCell.Value = ActiveCell.Value + ", " + UserForm10.CheckBox4.Caption
End If
If UserForm10.CheckBox5.Value = True Then
ActiveCell.Value = ActiveCell.Value + ", " + UserForm10.CheckBox5.Caption
End If
If UserForm10.CheckBox6.Value = True Then
ActiveCell.Value = ActiveCell.Value + ", " + UserForm10.TextBox1.Value
End If
UserForm10.Hide
End Sub
Here is a copy of the userform also: