If Combo Box Selection Text Include Specific Character

keromero

New Member
Joined
Feb 20, 2025
Messages
18
Office Version
  1. 2016
I want to show a message If combobox selected text includes a specific character such as "!"

Using: If InStr(ComboBox1.Text, "!")

I have already managed it however there is only one issue,

As long as I pick the combo box listed selection message shows up.

I just want the message to be popped up after selection done and list is closed. Not as the list is drop downed already.

Thanks
 
Try
VBA Code:
Private Sub ComboBox1_AfterUpdate()
MsgBox "Left box", vbOKOnly, "Msg" 'Your code here. Just put this here for you to test.
End Sub
 
Upvote 0
Actually I got it work @ AfterUpdate event. But this is not what I was looking for.

After update event waits until a next action such as clicking another combo box or entering a text box.

What I need an event simultaneously taking action with the drop down list close.
 
Upvote 0
Will this work?

VBA Code:
Private Sub ComboBox1_Change()
    MsgBox "Message", vbOKOnly, "Change" 'Your code here
End Sub
 
Upvote 0
This below code resolved...

Option Explicit

#If VBA7 Then
Private Declare PtrSafe Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
#Else
Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
#End If

Private Sub ComboBox1_Change()
SendKeyAPI VBA.vbKeyReturn
MsgBox ComboBox1.Value
End Sub

Private Sub SendKeyAPI(ByVal VKey As Byte)
Const KEYEVENTF_KEYDOWN = &H0, KEYEVENTF_KEYUP = &H2
Call keybd_event(VKey, 0, KEYEVENTF_KEYDOWN, 0)
Call keybd_event(VKey, 0, KEYEVENTF_KEYUP, 0)
DoEvents
End Sub
 
Upvote 0

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