List Box

     

  • List box enables the user to see all the data items in drop down list at once
  •  

    Explain about ADD Item method

     

  • Add Item method used to add an item to the list in List box and Combo Box
  •  

  • It adds an item for each row
  •  

    List Box Single Selection - Multi Selection

     

    List box - Single Selection - 0 = Single Selection
    List box - Multi Select - 1 = Multi Selection

     

    List Box - With Check boxes or Toogle Button

     

  • Check boxes for multiple Selection
  • Toogle Button for single Selection
  •  

     

    List Box Display types

     

     

    Download The Workbook

     

    List Box Add & Clear Values

     

  • Enables to add values to List BOx
  •  

    Private Sub CommandButton1_Click()
    For i = 1 To 11
    ListBox1.AddItem i
    Next
    End Sub
    Clear values from List box
    Private Sub CommandButton2_Click()
    ListBox1.Clear
    End Sub

     

    Download The Workbook

     

    List Box Add Sheet Names

     

    Private Sub CommandButton1_Click()
    Dim shcout As Integer
    shcout = Sheets.Count
    For i = 1 To shcout
    Range("A" & i).Value = Sheets(i).Name
    ListBox1.AddItem Sheets(i).Name
    Next
    End Sub
    'Clear ListBox
    Private Sub CommandButton2_Click()
    ListBox1.Clear
    Range(Range("A1"), Range("A1").End(xlDown)).Clear
    End Sub

     

     

    Download The Workbook

    List Box Add Values

     

    Private Sub CommandButton1_Click()
    ListBox1.AddItem 111
    ListBox1.AddItem 222
    ListBox1.AddItem 333
    ListBox1.AddItem 444
    ListBox1.AddItem 555
    ListBox1.AddItem 666
    End Sub Clear From list values
    Private Sub CommandButton2_Click()
    ListBox1.Clear
    End Sub

     

    Download The Workbook

     

     

    adding values to List Box

     

     

    Download The Workbook

     

     

    SELECTED Property of Listbox:

     

     

  • We use SELECTED property in case of MULTIPLE SELECTION
  •  

  • If SELECTED Is TRUE row in a LISTBOX will select
  •  

     

    Adding Serial Numbers through Listbox selection

     

  • Select the Sheet Names in LISTBOX., to Print serial numbers
  •  

     

    Download The Workbook

     

     

    Listbox multiple columns

     

     

  • For multiple columns we need to fill the COLUMNWIDTH & COLUMNCOUNT
  •  

     

     

     

    Download The workbook