listbox clear selections

smakatura

Board Regular
Joined
May 27, 2011
Messages
141
I have tried every possible combination to resolve this issue and can not find an answer. Ia about to pull all my hair out. most of the code I have tried produces an error.

the following code does NOT produce an error...but also does NOTHING.

Code:
Sub Fix_Font_size()

 Sheets("Distribution").OLEObjects("ListBox1").Object.Value = Null
End Sub


can someone please help
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
Code:
Sheets("Distribution").OLEObjects("ListBox1").Object.ListIndex = -1
 
Upvote 0
If you are referring to a multiselect listbox then:
Code:
Dim i As Long

With Sheets("Distribution").OLEObjects("ListBox1").Object
    For i = 0 To .ListCount - 1
        .Selected(i) = False
    Next i
End With
 
Upvote 0
This is an ActiveX ListBox with a known name on a known sheet... why are we vectoring through OLEObjects?

Code:
Sheets("Distribution").OLEObjects("ListBox1").Object.ListIndex = -1
Code:
Sheets("Distribution").ListBox1.ListIndex = -1


If you are referring to a multiselect listbox then:
Code:
Dim i As Long

With Sheets("Distribution").OLEObjects("ListBox1").Object
    For i = 0 To .ListCount - 1
        .Selected(i) = False
    Next i
End With
Code:
Dim i As Long

With Sheets("Distribution").ListBox1
    For i = 0 To .ListCount - 1
        .Selected(i) = False
    Next i
End With
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,164
Messages
6,170,444
Members
452,326
Latest member
johnshaji

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top