Any more effective method to get selected item in Listbox?

  • Thread starter Thread starter Danny
  • Start date Start date
D

Danny

Hi,

I have a question about the Userform.listbox

I would like to make a userform, which has 2 listbox. The first one
(listbox1) is showing the sheet name in workbook. Another (listbox2)
is showing the range(cells(1,1),cells(1,1).end(xltoright).column) of
select sheet name (selected at listbox1)

my normal practice to get selected item in listbox is below. Any more
effective method?
_______________________________________
k = userform.lisbox1.ListCount
j = 1
For i = 1 To k
If userform.lisbox1.Selected(i - 1) = True Then
ReDim Preserve Array(j)
Array(j) = i
j = j + 1
End If
Next i
_______________________________________
 
Thank you all,

how about if the selected items is more than one? Must need the loop
to determine?
 
Back
Top