Combo box change event not working

Av8tordude

Well-known Member
Joined
Oct 13, 2007
Messages
1,075
Office Version
  1. 2019
Platform
  1. Windows
i'm using the code below to delete the value in a combo box, which will trigger the code in the combo box. Sometimes it works and sometimes it doesn't, but I can't determine what causing it not to trigger the change event. From my understanding, since I'm deleting the value from the combo box, that should trigger a change event. Can someone offer some insight as to why its not working? BTW, I did debug through the code, I can see the value being deleted, but the change event does not trigger.

When I click enter command buttong, cbName = "" is suppose to delete the value in the combo box....

VBA Code:
If ActiveCell = vbNullString Then
    If obStock = True Then cbName = "" Else NewEntry
Else
    LogForm = True: Call Records
End If


when the value is delete, the code below (which is in the change event) is suppose to trigger..

VBA Code:
Private Sub cbName_Change()
Dim Result As Variant
Dim LRow As Long

cbName = UCase(cbName)
cbEnter.Enabled = Not Trim(cbName) = ""
LRow = Application.Max(7, Range("A" & Rows.Count).End(xlUp).Row)
Result = Application.VLookup(cbName, Range("A7:B" & LRow), 2, False)

clbinternet.Visible = IsConnected = False
clbScaleIO.Visible = Trim(cbName) > "" And cbT1.ListIndex < 2
clbSpread.Visible = Trim(cbName) > "" And cbT1.ListIndex = 2

If Trim(cbName) = "" Then
    NewEntry
Else
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
maybe in code you read the value, and after you no the value has changes you make that an IF THE event and call your change routine

A1 = 1

Test = A1

IF A1 <> Test then ....
 
Upvote 0
The problem is not in the cell, the problem is in the combo box itself. cbName = "" deletes the value from the combo box but does not trigger the change event. As I said before, sometimes it works and sometimes it doesn't.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,185
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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