Any more effective method to get selected item in Listbox?


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
_______________________________________
 
Ad

Advertisements

D

Danny

Thank you all,

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

Advertisements


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top