Young Grasshopper
Board Regular
- Joined
- Dec 9, 2022
- Messages
- 58
- Office Version
- 365
- 2016
- Platform
- Windows
Hi world,
I have this small userform with a multiselect listbox:
I'm trying to write a code which is run/looped for each selected item in the listbox, so im trying to set selection as Long.
So in the example in the picture
"Ma - pri 1.." would be 0
"Ma - Brand" would be 1
"Test 6 abc 7" would be 2
The values in the userform will be different each time it's used.
This is what I have now, but i get an error, and i really have no idea on how to do it, so the error don't surprise me..
Any suggestions?
I have this small userform with a multiselect listbox:
I'm trying to write a code which is run/looped for each selected item in the listbox, so im trying to set selection as Long.
So in the example in the picture
"Ma - pri 1.." would be 0
"Ma - Brand" would be 1
"Test 6 abc 7" would be 2
The values in the userform will be different each time it's used.
This is what I have now, but i get an error, and i really have no idea on how to do it, so the error don't surprise me..
VBA Code:
Sub CustomerPreview2()
Dim i As Long
For i = 0 To 99
For Each item In PreviewCampaignListbox.Selected
If PreviewCampaignListbox.Selected(i) = True Then
Worksheets("Sheet1").Range("G11:U11").Offset(i).SpecialCells(xlCellTypeConstants).Copy
ThisWorkbook.Worksheets("Sheet2").Range("B34").Offset(, i * 10).PasteSpecial Transpose:=True
Exit For
End if
Next
Next
End Sub
Any suggestions?