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


blank rowsum if condition in excelrept in excelhow to adjust cell width in excelhow to write an excel macroexcel unlock cellsexcel vba last rowexcel case statementsample vbasumif formula in excel 2010 with examplemicrosoft excel basics tutorialexcel isna formulaexcel vba tutorialsproject timeline template pptexcel 2010 pivot table tutorialexcel macro write to text filedelete blanksexcel macro buttonsautomation testing interview questions and answers for freshershow to remove the duplicates in excelaverage vbavba excel sort columnhow to make if statements in excelvbscript listboxdaily scrum meeting templateloop function vbaexcel remove duplicate rowexcel macro to copy data from one workbook to anothersas training for beginnerslinking pivot tablesvba structurehow to select different rows in excelvbscript write to filehow to delete rows on excelunhide columns in excel 2010macro to remove duplicatesinsert radio button in excelapplication calculation xlcalculationautomaticvba macro loopopen xml file in excel 2010xml to excel convertorhow to identify duplicates in excelvba excel columnsvba on error msgboxxls macroexcel task management templateexcel vba sheet nameworking with arrays in vbaexcel 2007 listboxunlock excel 2010 password protected filevba macros for beginnerscountifs function in excel 2007blank checks worksheetvb6 rename fileadodb.recordset openexcel concanatedatediff excel vbaexamples of macros in wordexport from excel to access vbaaccess vba sql selectvba code loopmerging cell in excelboolean vbagantt chart template excel 2003insert macro in excelexcel workbook tabstrim in exceltrim function in vbaexcel vba vbyesnoexcel vba set background colorworksheet on coloursexcel vba hide columnif statements in excel 2007limitation of vlookupsort order sqlvlookup in excel 2003sumif excel examplehow to use sumif formula in excel