Using ComboBox Change or Click event with IF or Case statement

julhs

Active Member
Joined
Dec 3, 2018
Messages
409
Office Version
  1. 2010
Platform
  1. Windows
Yet again I can’t compile the syntax to get the desired outcome.
What I am trying to achieve is;
If ComboBox20 is Changed or Clicked, EITHER D22 or E22 will be selected DEPENDENT on whether D22 is greater than "", or E22 is greater than "".
Note; D22 and E22 will NEVER BOTH be greater than "", it can only be one or the other.
To summerise;
If ComboBox20 is Changed or Clicked and D22 is greater than "", then D22 is selected
Or
If ComboBox20 is Changed or Clicked and E22 is greater than "", then E22 is selected

I've tried various different approches but all have failed.
 
Where did GetFocus come from? I can't tell if you're asking about code or user actions because I don't think there is anything called GetFocus (unless it was a user defined function - UDF).

If you mean GotFocus then no, they are not the same thing.
Are you trying to use a wild card with * ? Can't do it that way. Would have to use LIKE operator.
If the value is really "Check Entry value" why not just use that? Otherwise,
If Range("D24") LIKE "Check*" Then
 
Upvote 0

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
I got “Get Focus” from your post #8, but I may have miss-interrupted actually what you meant?
AFAIK, Click event code won't fire a combo on a sheet. Does for Access though, which is kinda stupid. Maybe you can use Dropdown as suggested, or GotFocus event, or both if needed.
In the intervening time, I had abandoned using wildcards (*) and had actually resorted to what you have suggested.
It did require a degree of extra coding, but that was fine to get the desired outcome.
At this point I’ve not tried using “Like” but will test it out.
Since I last posted I have been dealing with other aspects of this whole spreadsheet, so only now come back to this query.
Still other bits I need to address before I can properly come back to this.
Many thanks for your input to date.
 
Upvote 0

Forum statistics

Threads
1,215,430
Messages
6,124,846
Members
449,194
Latest member
HellScout

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