VB list box how to obtain text in selected rows ?

W

wojjed

Hi

Here's how i fill the list :

Private Sub CommandButton1_Click()

Dim sFilename As Variant

sFilename = Application.GetOpenFilename("Excel files (*.xls; *.csv),
*.xls; *.csv", 0, "Wybierz pliki", 0, True)

For Y = 1 To UBound(sFilename)
ListBox1.AddItem (sFilename(Y))
Next

End Sub

When files are selected i want to open them using Workbooks.Open
(sFilename(Y)) - but in loop that method doesnt work - why ? And how
to obtain text in selected rows ? Supose i have
Private Sub CommandButton2_Click() in which i want to open selected
files - how to do it ?


thx for all sugestions
 
G

Guest

Are you sure you are posting in the right group?

????Dim sFilename as Variant?????
Sounds like VB6 to me, in which case look at the ListBox.Selected(index)
property.

If .Net, look at ListBox.SelectedItems property.
 

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