PDA

View Full Version : Populate UF Listbox then send to Spreadsheet



Emoncada
02-06-2012, 10:26 AM
I have several checkboxes in a Userform that when True will Show a textbox next to it for a value.

I want to build a listbox or Textbox with the caption of the checkboxes that are true with it's value next to it.

Then when update is clicked send the listbox or textbox values to a cell.
They can be seperated by a semicolon.

How can I make this happen?

Bob Phillips
02-06-2012, 11:06 AM
In each of the checkbox's Tag property, input the name of its associated Textbox, and use this



Private Sub CommandButton1_Click()
Dim ctl As Object
Dim output As String

For Each ctl In Me.Controls

If TypeName(ctl) = "CheckBox" Then

If ctl.Value Then

output = output & ctl.Caption & " - " & Me.Controls(ctl.Tag).Text & vbNewLine
End If
End If
Next ctl

ActiveSheet.Range("M1").Value = output
End Sub

Emoncada
02-06-2012, 11:20 AM
I see what you mean, is it possible to have the comment box with the checkbox.caption and value updated as it's entered?

I have a Userform That I will fill out and check the boxes, enter it's values and when I am all done, I would like to see the list with it's values in a textbox. Then I would click the update button and send all data to the spreadsheet. I have the following code to send data to spreadsheet

If UserFormOutgoing.CmbBoxSN1.Value <> "" Then
.Cells(RowNext1, 1) = UserFormOutgoing.CmbBoxModel1.Value
.Cells(RowNext1, 2) = UserFormOutgoing.CmbBoxSN1.Value
.Cells(RowNext1, 3) = UserFormOutgoing.TxtName1.Value

That's an example.

Bob Phillips
02-06-2012, 12:35 PM
Not sure exactly what you want in this case.

Emoncada
02-06-2012, 01:02 PM
I would like to have a textbox or listbox on the side of the userform recieve this information from the checked boxes. Kind of like a reciept.
So when someone clicks a checkbox and after they enter a value the textbox/listbox will show that information. Then after all is selected and list of items is in textbox when update button is clicked it sends all that information to that cell.

hope that helps explain. Thanks for the help