Forum

How to Prevent Same...
 
Notifications
Clear all

How to Prevent Same Selection from Lists in Two Combo boxes in VBA

2 Posts
2 Users
0 Reactions
135 Views
(@nash2405)
Posts: 1
New Member
Topic starter
 

Hi,

Need assistance, I have created a form for my team which has 2 combo box and their are same names for selection in both the combo box and I need to make sure that the user can't select the same name if they have already selected it in either of the combo box.

 

Can someone please help. 

 

Below is the code written 

 

Sub Reset()

Dim Irow As Long

Irow = [Counta(Database!A:A)] ' idetiying the last row

With frmForm

.txtNAME.Value = ""
.cmbDM.Clear
.txtDATE.Value = Date
.optWaterfall.Value = False
.optAgile.Value = False
.cmbDOD.Clear

.cmbDM.AddItem "Accept Core MOPs"
.cmbDM.AddItem "Accept ALT Mops"
.cmbDM.AddItem "Digital Connect"
.cmbDM.AddItem "Field"
.cmbDM.AddItem "Inform"
.cmbDM.AddItem "POS Solution"
.cmbDM.AddItem "Servicing"
.cmbDM.AddItem "Value Added Services"

.cmbDOD.AddItem "TBD"
.cmbDOD.AddItem "Yes"
.cmbDOD.AddItem "No"

.txtRowNumber.Value = ""

.txtEXPTC.Value = ""
.txtACTC.Value = ""

.cmbTDC.Clear

.cmbTDC.AddItem "TBD"
.cmbTDC.AddItem "Self Created"
.cmbTDC.AddItem "Mixed"
.cmbTDC.AddItem "External"

.cmbPT.Clear
.cmbST.Clear

.cmbPT.AddItem "Divya Sivananda"
.cmbPT.AddItem "Francis G Burton"
.cmbPT.AddItem "Jane Reid"
.cmbPT.AddItem "Jeffrey R Wyman"
.cmbPT.AddItem "Latha Madasu"
.cmbPT.AddItem "Mauric Wimms"
.cmbPT.AddItem "Mohammed S Shaikh"
.cmbPT.AddItem "Mubin Bharde"
.cmbPT.AddItem "Nishit Bhatt"
.cmbPT.AddItem "Nolan Jones"
.cmbPT.AddItem "Ram Pandey"
.cmbPT.AddItem "Rugved Phatak"
.cmbPT.AddItem "Shamekia R Keaton"
.cmbPT.AddItem "Sunam Koirala"
.cmbPT.AddItem "Swapna Malkan"
.cmbPT.AddItem "Tiffany A Blevin"
.cmbPT.AddItem "Trupti Kulkarni"

.cmbST.AddItem "Divya Sivananda"
.cmbST.AddItem "Francis G Burton"
.cmbST.AddItem "Jane Reid"
.cmbST.AddItem "Jeffrey R Wyman"
.cmbST.AddItem "Latha Madasu"
.cmbST.AddItem "Mauric Wimms"
.cmbST.AddItem "Mohammed S Shaikh"
.cmbST.AddItem "Mubin Bharde"
.cmbST.AddItem "Nishit Bhatt"
.cmbST.AddItem "Nolan Jones"
.cmbST.AddItem "Ram Pandey"
.cmbST.AddItem "Rugved Phatak"
.cmbST.AddItem "Shamekia R Keaton"
.cmbST.AddItem "Sunam Koirala"
.cmbST.AddItem "Swapna Malkan"
.cmbST.AddItem "Tiffany A Blevin"
.cmbST.AddItem "Trupti Kulkarni"

.lstDatabase.ColumnCount = 13
.lstDatabase.ColumnHeads = True

.lstDatabase.ColumnWidths = "30,200,100,75,75,60,60,60,75,100,100,100,100"

If Irow > 1 Then

.lstDatabase.RowSource = "Database!A2:M" & Irow

Else

.lstDatabase.RowSource = "Database!A2:M2"

End If

End With

 
Posted : 14/04/2020 8:41 am
Philip Treacy
(@philipt)
Posts: 1629
Member Admin
 

Hi Nishit,

Please see attached workbook for working solution.

Couple of things.  In the code you sent, you are referencing a control called txtDATE that does not exist.  I had to comment out any lines referencing this that I came across, there may be more that need fixing.

You've named the Full Time Team Member combobox cmbPT and the Part Time Team Member combobox cmbST.  I'd expected the Full Time box to be cmbFT and the Part Time one cmbPT?

Regards

Phil

 
Posted : 15/04/2020 7:04 pm
Share: