Results 1 to 3 of 3

problem vba code for multiselect listbox (userform)

Threaded View

  1. #1
    Forum Contributor
    Join Date
    10-07-2015
    Location
    cyprus
    MS-Off Ver
    Microsoft 365
    Posts
    183

    problem vba code for multiselect listbox (userform)

    in the attached file, I drafted a userform "PANDL" (which is actually the copy of the page 2 of the userform "cargo2016").

    In this userform I would have like to be able to select several ref and to populate the userform with infos for each of them..

    But my knowledge in VBA is null and I don't know how to say for each selected item in the listbox "REF", get datas.....

    I tried to put a "ok" command to validate the selection in REF listbox with following code...

    Private Sub cmdOkay_Click()
    Dim i As Long, msg As String, Check As String
    
    'Generate a list of the selected items
    
        For i = 0 To Me.REF.ListCount - 1
            If Me.REF.Selected(i) Then
            GetData
            End If
        Next i
    
    
    If msg = vbNullString Then
        'If nothing was selected, tell user and let them try again
        MsgBox "Nothing was selected!  Please make a selection!"
        Exit Sub
    Else
        'Ask the user if they are happy with their selection(s)
        Check = MsgBox("You selected:" & vbNewLine & msg & vbNewLine & _
            "Are you happy with your selections?", _
            vbYesNo + vbInformation, "Please confirm")
    End If
    
    If Check = vbYes Then
        GetData
    Else
        'User wants to try again, so clear listbox selections and
        'return user to the userform
        For i = 0 To REF.ListCount - 1
            REF.Selected(i) = False
        Next
    End If
         
    End Sub
    but obviously the ref.value remain "null".....

    can someone give me some tips to search further?
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. UserForm: Enable Textbox When "Other" Selected in MultiSelect Listbox (Excel 2010)
    By excelforumkeys in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 01-02-2014, 06:40 PM
  2. Listbox multiselect- VBA code error
    By sassy1978 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-08-2013, 07:22 PM
  3. [SOLVED] MultiSelect Listbox in Userform to copy data to worksheet
    By aarodn in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 06-06-2013, 03:52 PM
  4. Copy Selected items from multicolumn, multiselect listbox to another listbox
    By Willigb in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-19-2013, 11:27 AM
  5. [SOLVED] listindex=0 when first item selected in a multiselect listbox on a userform?
    By mcdermott2 in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 04-17-2013, 12:38 PM
  6. Unable to Detect When UserForm MultiSelect ListBox Selection Changes
    By ShortSword in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-07-2012, 10:49 PM
  7. How to adapt this listbox code when multiselect is enabled?
    By Kimberley in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 12-02-2011, 02:00 PM
  8. userform multiselect listbox problem
    By apndas in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-24-2006, 11:12 PM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1