Consulting

Results 1 to 2 of 2

Thread: Userform checkbox captions to a cell

  1. #1

    Userform checkbox captions to a cell

    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/show...t=12261&page=2 )
    Can anybody also tell me how to solve this? Thanks.

  2. #2
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    [VBA]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[/VBA]
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •