How to add TextChanging Event to ActiveX Combobox?

AlexExcel2021

New Member
Joined
Feb 23, 2023
Messages
25
Office Version
  1. 2021
Platform
  1. Windows
I have add Combobox to page.

Dim Combo As ComboBox
Set Combo = ActiveSheet.OLEObjects.Add(ClassType:="Forms.ComboBox.1", Link:=False, DisplayAsIcon:=False, Left:=50, Top:=80, Width:=100, Height:=15).Object

And I need to add TextChanging events to this Combobox, but how to do this?
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
In a Module, use this to create combobox:

VBA Code:
Sub createcombo()
  Dim Combo As ComboBox
  Dim TheComboName As String
  
  TheComboName = "MyCombo"
  On Error Resume Next
    ActiveSheet.OLEObjects(TheComboName).Delete
  On Error GoTo 0
  
  Set Combo = ActiveSheet.OLEObjects.Add(ClassType:="Forms.ComboBox.1", _
    Link:=False, DisplayAsIcon:=False, Left:=50, Top:=80, Width:=100, Height:=15).Object
  Combo.Name = "Mycombo"
End Sub

In the sheet event:
VBA Code:
Private Sub Mycombo_Change()
  MsgBox "TextChanging"
  'do some
End Sub

SHEET EVENT
Right click the tab of the sheet you want this to work, select view code and paste the code into the window that opens up.
 
Upvote 0
Solution

Forum statistics

Threads
1,214,819
Messages
6,121,741
Members
449,050
Latest member
excelknuckles

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