PDA

View Full Version : Userform checkbox captions to a cell



icegg
04-19-2007, 12:12 PM
I have a userform containing 12 checkboxes. I want to put the captions of the checked boxes into an active cell with each caption seperated by a comma, like this "Jan, Mar, May". Can anybody help me with this? Thanks a lot.

This is posted originally in another thread. I tried to upload the file again. But it won't let me: "You have already attached this file in thread : Inputing Userform data into spreadsheet (http://www.vbaexpress.com/forum/showthread.php?t=12261) " (http://www.vbaexpress.com/forum/showthread.php?t=12261&page=2 )
Can anybody also tell me how to solve this? Thanks.

mdmackillop
04-19-2007, 12:38 PM
Private Sub CommandButton1_Click()
Dim i As Long, txt As String
For i = 1 To 12
If Me.Controls("Checkbox" & i) = True Then
txt = txt & Me.Controls("Checkbox" & i).Caption & ", "
End If
Next
txt = Left(txt, Len(txt) - 2)
Cells(1, 1) = txt

End Sub