Reputation: 11
my userform contains a combobox and a command button.
the combo box list is populated by range("clmA") by identifying my range clmA in the row source field in the my combobox's properties. (NO VBA was used to populate the list)
I want a sub button_click() to select the row of data identified by the value in the combobox and paste the row into another worksheet.
The copy and pasting code should not be a problem I hope however I can't seem to reference or select the value in the combo box.
I am just learning VBA, I am learning by reading this website and using the macro recorder.
Upvotes: 0
Views: 3067
Reputation: 6984
Change the columns to whatever you need,
Private Sub CommandButton1_Click()
Dim ws As Worksheet
Dim Drng As Range, c As Range
Set ws = Sheets("Data")
Set Drng = ws.Columns("A:A").SpecialCells(xlCellTypeConstants, 23)
For Each c In Drng.Cells
If c = ListBox1 Then
Range(Cells(c.Row, "A"), Cells(c.Row, "D")).Copy Sheets("Summary").Cells(Rows.Count, "A").End(xlUp).Offset(1, 0)
End If
Next c
Unload Me
End Sub
Upvotes: 0