ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Duplicates? (https://www.excelbanter.com/excel-programming/332870-duplicates.html)

browie

Duplicates?
 
Hi all
I have a userform with 8 combobox's and I have them all linked to the same
row sources. How can I stop the user from selecting a same value as another
combobox in this group

Thanks in advance



Bob Phillips[_6_]

Duplicates?
 
Couldn't you use the click event to test it?

Private Sub ComboBox1_Change()
CheckValue ComboBox1
End Sub

Private Sub ComboBox2_Change()
CheckValue ComboBox2
End Sub

Sub CheckValue(Combo As MSForms.ComboBox)
Dim oCtl As Control

For Each oCtl In Me.Controls
If TypeName(oCtl) = "ComboBox" Then
If oCtl.Name < Combo.Name Then
If oCtl.ListIndex < -1 Then
If Combo.Value = oCtl.Value Then
MsgBox "Duplicate"
oCtl.ListIndex = -1
End If
End If
End If
End If
Next oCtl
End Sub


--

HTH

RP
(remove nothere from the email address if mailing direct)


"browie" wrote in message
...
Hi all
I have a userform with 8 combobox's and I have them all linked to the same
row sources. How can I stop the user from selecting a same value as

another
combobox in this group

Thanks in advance






All times are GMT +1. The time now is 02:14 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com