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


working with macros in excel 2007vba worksheet deleteadodb sql server connection stringsql and sas trainingvba scripting.filesystemobjectexcel adodb connectionvba application functionisnumber function in excelexcel function vbaexcel duplicate deleteuserform vba exampleexcel coding tutorialsas basics tutorialidentify duplicates in excelsql sasprotect worksheet excel 2007excel formula to remove blank rowshow to protect excel workbook with passwordexcel macro inputboxprogramming macros in excelexcel vba protect all sheetsvba excel column widthexcel dashboards and reports 2010vba code to read excel fileremove dupes in excelexcel vba formattingcopy duplicates in excelexcel macro usesdelete row vbaexcel formula for adding columnsselect range in vbahow to remove excel sheet passwordexcel query databasedelete row in excel shortcutvba code to copy and pastehow to make excel sheet password protectededit hyperlink in excelpivot table limitsvba msgvba code to open excel file from folderaccess vba function return valueaccess vba userformunprotecting an excel worksheetdownloadable excel templatestcs business analyst interview questionsinteger vbaadvanced excel tutorial pdf 2010how do you unhide rows in exceldelete a row vbabasic excel shortcutsexcel if statement blankmacro security excel 2007using vlookup in vbausing excel lookupvba excel 2007 tutorialmacro password crackerdashboard charts in excelvba copyfileunlock xls passwordfind duplicates in excellvba spreadsheet controlexcel vba match functionlocate duplicates in excelribbon tab in excelexcel how to delete empty rowsadodb recordset in vbamicrosoft office project management templatesexcel vba programmicrosoft excel quick keysexcel vba select cellhr round interview questions and answers for experienced pdfwriting a macro in exceldebug print vbasql introduction for beginnersmacro learning in excelsql interview questions for freshervba project downloadexcel bubble chart