Results 1 to 2 of 2
  1. #1
    3 Star Lounger MacroAlan's Avatar
    Join Date
    Feb 2003
    St Louis, Missouri, USA
    Thanked 1 Time in 1 Post

    Capture Array Items from Listbox (VBA/Excel/2002)

    I have a ListBox that was created from an array that has 2 hidden columns and 1 that is displayed. The 2 hidden columns contain info I want to pass to another procedure.

    What I have to read and collect the chosen rows does not seem to let me capture all 3 columns. I need the data in them to pass to a Stored Procedure.
    <pre>NumberofItemsSelected = 0
    For i = 0 To TotalLines - 1
    If lstContainer.Selected(i) Then
    NumberofItemsSelected = NumberofItemsSelected + 1
    ReDim Preserve SelectedLineItems(NumberofItemsSelected)
    SelectedLineItems(NumberofItemsSelected) = lstContainer.List(i)
    End If</pre>

    I tried doing something like SelectedLineItems(NumberofItemsSelected) = lstContainer.List(i,0) but it blows up. Do I need to define SelectLineItems as a multi-dimensional array?

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Thanked 28 Times in 28 Posts

    Re: Capture Array Items from Listbox (VBA/Excel/2002)

    Try this:

    Dim i As Integer
    Dim j As Integer
    Dim TotalLines As Integer
    Dim NumberofItemsSelected As Integer
    Dim SelectedLineItems()

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts