Error Checking in Excel
Thanks Thanks:  0
Likes Likes:  0
Results 1 to 4 of 4

Thread: ListBox Control

  1. #1
    Guest

    Default

    Hi,
    I have a ListBox control in my userform. The source would be some cells in my excel sheet. Basically, how do I tell if an entry in the listbox is selected?? Something like..

    For all entries in listbox1
    if an entry is selected then
    msgbox entries.value
    end if
    end for

    What's the correct syntax to perform such action? Thanks guys

  2. #2
    Rest in Peace
    Join Date
    Feb 2002
    Posts
    1,582
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Hi

    I take it you have the MultiSelect Property set to Multi?

    If so here is some code from a file I am currently working on.



    Dim UnitsToPrint as Integer
    Dim bHaveOne as Boolean

    UnitsToPrint = 0
    For i = 0 To UnitListBox.ListCount - 1
    If UnitListBox.Selected(i) = True Then
    iRow = iRow + 1
    Sheet20.Cells(iRow, 26) = UnitListBox.List(i)
    UnitsToPrint = UnitsToPrint + 1
    bHaveOne = True
    End If
    Next i

    If bHaveOne = False Then 'No Units selected
    MsgBox "You have not selected any record(s) to print.", vbCritical, "Nothing to print!"
    Exit Sub
    End If




  3. #3
    Guest

    Default

    Hey, Thanks... Really helps

  4. #4
    Rest in Peace
    Join Date
    Feb 2002
    Posts
    1,582
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Pleasure!



Some videos you may like

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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