Hi - I’ve got a worksheet with multiple ListBox form controls (not ActiveX) that I need to extract the selections/inputs from.
There are 6 different listboxes all with multiple selection and about 40x of each. They are aligned by row, e.g customer 1 in in row 1 has listbox 1 in column A, listbox 2 in column B, listbox 3 in column C and so on.. this is repeated for customer 2 in row 2, customer 3 in row 3 and so on..
The perfect solution would delimit the multiple inputs for each listbox with a comma, but I could potentially work around this.
I’ve got some experience with VBA and have been able to extract the inputs of a single listbox (not delimited in a single cell however), but have been unable to loop through all of the listboxes and get the rest of the selection data.
The code I’ve used extracts from List Box 1660 into Sheet 1 C4:
Dim lb As Object
Dim i As Long
Dim c As Integer
Dim col As Integer
Dim Ws As Worksheet
Set Ws = Sheets("ReportingInventory")
Set lb = Worksheets("ReportingInventory").Shapes("List Box 1660")
If lb.Type = msoFormControl Then
If lb.FormControlType = xlListBox Then
For i = 1 To lb.OLEFormat.Object.ListCount
If lb.OLEFormat.Object.Selected(i) Then
c = c + 1
Sheets("Sheet1").Activate
ActiveSheet.Cells(c + 1, 4) = lb.OLEFormat.Object.List(i)
End If
Next i
End If
End If
End Sub
Any help would be appreciated!
There are 6 different listboxes all with multiple selection and about 40x of each. They are aligned by row, e.g customer 1 in in row 1 has listbox 1 in column A, listbox 2 in column B, listbox 3 in column C and so on.. this is repeated for customer 2 in row 2, customer 3 in row 3 and so on..
The perfect solution would delimit the multiple inputs for each listbox with a comma, but I could potentially work around this.
I’ve got some experience with VBA and have been able to extract the inputs of a single listbox (not delimited in a single cell however), but have been unable to loop through all of the listboxes and get the rest of the selection data.
The code I’ve used extracts from List Box 1660 into Sheet 1 C4:
Dim lb As Object
Dim i As Long
Dim c As Integer
Dim col As Integer
Dim Ws As Worksheet
Set Ws = Sheets("ReportingInventory")
Set lb = Worksheets("ReportingInventory").Shapes("List Box 1660")
If lb.Type = msoFormControl Then
If lb.FormControlType = xlListBox Then
For i = 1 To lb.OLEFormat.Object.ListCount
If lb.OLEFormat.Object.Selected(i) Then
c = c + 1
Sheets("Sheet1").Activate
ActiveSheet.Cells(c + 1, 4) = lb.OLEFormat.Object.List(i)
End If
Next i
End If
End If
End Sub
Any help would be appreciated!