Code to Validate Combo Boxes on a Form

TheNoocH

Well-known Member
Joined
Oct 6, 2004
Messages
3,482
I have 9 combo boxes cmbOption01 to cmbOption09.
What i want to do is validate that none of the 9 option boxes have the same value (note: not all option boxes will be selected all the time...thus multiple ones can have blank).

I got the theory to work using:
Code:
Sub Private cmbOption02_Change()
If Me.cmbOption01.Value=Me.cmbOption02.Value Then
MsgBox "Duplicate option entered"
End If
End Sub

My issues are how do i do it so i can evaluate all 9 options at once and ignore when they are blanks.
Plus is the OnChange the right place to put this?

Any help would be great.
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
I personally like the _afterupdate event because it's after the user has changed the value of the combobox.

What you could do is iterate through all 9 combo-boxes and check each. A cleaner way to do this would be to build SQL that excludes all 'prior' values but it can get messy and cumbersome fast.

Mike
 
Upvote 0

Forum statistics

Threads
1,221,831
Messages
6,162,252
Members
451,757
Latest member
iours

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