How to have an empty combobox when i open a sheet ?

otrava18

Board Regular
Joined
Feb 11, 2018
Messages
61
Hello all,

I have a question for you. I have 10 x activex combobox named from Player1 to Player10. When i open the sheet the CB is already fill with the last value. How can i set all the CB to be empty when i open the sheet ? I find only information about setting ListIndex on -1, but i don`t know how to do that when i open the sheet or if it is a solution for me.

Thank you !
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
.

Paste in a Regular Module :

VBA Code:
Option Explicit

Sub ComboStrt()
    Sheets("Sheet1").ComboBox1.Value = Null
End Sub

Paste in the ThisWorkbook Module:

Code:
Option Explicit

Private Sub Workbook_Open()
    ComboStrt
End Sub
 
Upvote 0
Hello ,

I use the first part like this. I`m not sure that it is ok because it doesn`t work. How can i enter the name of the ComboBox ?

VBA Code:
Option Explicit

Sub ComboStrt()
    Sheets("Sheet1").Player1.Value = Null
End Sub
 
Upvote 0
.
OK ... previously I suggested pasting code in the ThisWorkbook module. Disregard that completely.

Paste the following in the SHEET MODULE.


VBA Code:
Option Explicit

Private Sub Worksheet_Activate()
Dim sht     As Worksheet
Dim oOLE    As Object

Set sht = Sheets("Sheet1")      '<------ Change sheet name here
Application.ScreenUpdating = False
    
With sht
    For Each oOLE In sht.OLEObjects
        If TypeName(oOLE.Object) = "ComboBox" Then
            oOLE.Object.Value = Null
        End If
    Next
End With

Application.ScreenUpdating = True

End Sub

The above macro will clear all comboboxes on the worksheet.
 
Upvote 0

Forum statistics

Threads
1,214,827
Messages
6,121,812
Members
449,048
Latest member
greyangel23

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