ListBox Enabled Property

VBA Enabled Property of ListBox control is used to respond to user interaction. It sets or gets a value either ‘true’ or ‘False’. When the enabled property is ‘True’ user can access the listbox and we can change the selection. Or we can select the items in the listbox.

PREMIUM TEMPLATES LIMITED TIME OFFER

ON SALE80% OFF

50+ Project Management Templates Pack
Excel PowerPoint Word

Advanced Project Plan & Portfolio Template
Excel Template

Business Presentations Templates Pack
PowerPoint Slides

20+ Excel Project Management Pack
Excel Templates

20+ PowerPoint Project Management Pack
PowerPoint Templates

10+ MS Word Project Management Pack
Word Templates


Enabled Property Excel ListBox Object

ListBox_Enabled_Property – Syntax

Please find the below syntax of ListBox_Enabled_Property in Excel VBA.

ListboxName.Enabled=True or False

Where ListboxName represents the ListBox object. In the above syntax we are using ‘Enabled’ property of ListBox object to enable the listbox control.

ListBox_Enabled_Property – Explanation & Example

Here is the example for ListBox control Enabled_Property. It will take you through how to enable listbox control property of listbox using Excel VBA. Here you can find or see how we enable listbox using ‘Enabled’ property of listbox manually or using code.

ListBox_Enabled_Property: Change Manually

Please find the following details how we are changing manually ‘Enabled’ of listbox property.

  1. Go To Developer Tab and then click Visual Basic from the Code or Press Alt+F11.
  2. Go To Insert Menu, Click UserForm. Please find the screenshot for the same.
  3. Excel VBA UserForm CheckBox

  4. Drag a Listbox on the Userform from the Toolbox.
  5. List Box BackColor Property

  6. Right click on the List box. Click on properties from the available list.
  7. List Box BackColor Property2

  8. Now you can find the properties window of listbox on the screen. Please find the screenshot for the same.
  9. List Box Properties

  10. On the left side find ‘Enabled’ property from the available List Box properties.
  11. On the right side you can choose True or False from the available options.
  12. For example, you can see here I have choosen ‘True’. You can see the same in the screen shot for your understand.
  13. List Box Enabled Property

    ListBox_Enabled_Property: Change Using Code

    Please find the following details how we are changing Enabled of listbox property with using Excel VBA code.

    1. Go To Developer Tab and then click Visual Basic from the Code or Press Alt+F11.
    2. Go To Insert Menu, Click UserForm. Please find the screenshot for the same.
    3. Excel VBA UserForm CheckBox

    4. Drag a Listbox on the Userform from the Toolbox. Please find the screenshot for the same.
    5. List Box Excel ActiveX Control _Im10

    6. Double Click on the UserForm, and select the Userform event as shown in the below screen shot.
    7. List Box Excel ActiveX Control _Im1

    8. Now can see the following code in the module.
    9. Private Sub UserForm_Initialize()
      End Sub
      
    10. Now, add the following example code1 or code2 to the in between above event procedure.
    11. Example Code1:

      Here is the example for enabled property of listbox control. when we set the enabled property is ‘True’, user can access the listbox and we can change the listbox items selection. Or we can select the items in the listbox.

      'Enabled Property of ListBox Control
      Private Sub UserForm_Initialize()
      With UserForm1.ListBox1
      'ListBox Source Data
      .RowSource = "A2:A10"
      'The below statement will show header in each column
      .ColumnHeads = True
      'The below statement enable the listbox and will respond to user interaction
      ListBox1.Enabled = True
      End With
      End Sub 
      
    12. Now, Press ‘F5’ to see the following Output.
    13. Output: If Enabled =True
      Please find the below output when we set Enabled property to ‘True’. It is shown in the following Screen Shot.

      List Box Enabled Property

      Example Code2:

      When the enabled property is ‘False’ user can’t access the listbox manually and we cann’t change the listbox selection. And we can’t select the items in the listbox.

      'Enabled Property of ListBox Control
      Private Sub UserForm_Initialize()
      With UserForm1.ListBox1
      'ListBox Source Data
      .RowSource = "A2:A10"
      'The below statement will show header in each column
      .ColumnHeads = True
      'The below statement will not respond to user interaction
      ListBox1.Enabled = False
      End With
      End Sub
      
    14. Now, Press ‘F5’ to see the following Output.
    15. Output: If Enabled =False
      Please find the below output when we set Enabled property to ‘False. It is shown in the following Screen Shot.

      List Box Enabled Property

LIMITED TIME OFFER

Leave A Comment


Related pages


sort the selected table in ascending orderms excel pivot table tutorialmultiple project tracking template excelpassword to unprotect excel sheetexcel button for macroclose workbook vbatotal number of rows and columns in excel 2007vba loopingrun vba codesql developer interview questions and answers pdfexcel 2007 dashboard tutorialprotect excel sheet with passwordunprotect workbook vbascreenupdating vbacombining data from multiple worksheetsvba code for yes no message boxexcel macro end of columnexcel 2007 autofit row heightexcel vba saveexcel vba save as csvhow to remove blank rows in excel 2007excel vba programming for dummies pdfexcel 2013 sumifexample excel macrovba pivot tablesvariant data type in vbhow to copy cells in excel with formulaexcel vba rows.counthow to use data validation in excel 2013subroutine vbamicrosoft excel vba referencedefinition of vlookup functionactivate hyperlinks in excelagenda template excelexcel vba copy workbookprograming in excelcan you merge cells in excelword vbaexcel vba report exampleremove macros excelexcel look up functionhlookup formula in excel 2010trim function in vbaactivesheet vbaproject plan gantt chart excel templatehow to put password on excel 2007excel interactive dashboard templateinterview questions and answers for programmerhow to delete comment in excelunmerging cells in excelwhat are the ddl commands in sqlcase vbaproject timeline template excelvb dircreating pivot tables in excel 2007unlock spreadsheet without passwordwhat is ascending order in exceldelete entire row vbavb file handlingexcel tab shortcutexcel vba code listloop macro excelexcel vba copy and pasteprograming in excelexcel interactive dashboard templatevba open workbookexcel template for project trackingvbscript msgbox examplesexcel vba if cell containssumifs examplesexcel collection vbaslicer in excel 2010 tutorialvba nested if