Afternoon everybody,
I have contsructed a userform which consists of 2 Comboboxes boxes and 3 textboxes.
The comboboxes give the user an option to select Customer (combobox1) & Month (combobox 2)
The 3 Text boxes then allow the user to input various figures (not important)
Whnt the user clicks the command button the data on the userform is dumped into a spread sheet in 5 columns
the macro also check for the next empty row prior to dumping.
This portion of the macro works fine, however it dawned on me that with this set up the user would be able to enter duplicate data by selecting the same camobinations of customer and Month
(i.e Cust A Jan)
So I needed a method of preventing the Op from doing this, previousley I have used the code (below) to check for duplcate week no's in a given column,which worked well.
However I am struggling to modify it to look for 2 ducplicate conditions
(i.e To check that Customer A doesnt have more than one entry for January, February etc,)
Bearing in mind that in the first 2 columns there will be mulitple duplicates for customer and Month
i.e
Cust A Jan
Cust B Jan
Cust A Feb
Cust B Feb
etc etc...
Hope this is clear?
So my question is does any know how I can either modify the code below or have any different code that would aloow me to check for duplicates?
Thank you in advance for any Help!!
I have contsructed a userform which consists of 2 Comboboxes boxes and 3 textboxes.
The comboboxes give the user an option to select Customer (combobox1) & Month (combobox 2)
The 3 Text boxes then allow the user to input various figures (not important)
Whnt the user clicks the command button the data on the userform is dumped into a spread sheet in 5 columns
the macro also check for the next empty row prior to dumping.
This portion of the macro works fine, however it dawned on me that with this set up the user would be able to enter duplicate data by selecting the same camobinations of customer and Month
(i.e Cust A Jan)
So I needed a method of preventing the Op from doing this, previousley I have used the code (below) to check for duplcate week no's in a given column,which worked well.
However I am struggling to modify it to look for 2 ducplicate conditions
(i.e To check that Customer A doesnt have more than one entry for January, February etc,)
Bearing in mind that in the first 2 columns there will be mulitple duplicates for customer and Month
i.e
Cust A Jan
Cust B Jan
Cust A Feb
Cust B Feb
etc etc...
Hope this is clear?
So my question is does any know how I can either modify the code below or have any different code that would aloow me to check for duplicates?
Code:
'Check For duplicate Week No Entry
With ws
If MsgBox("Are All Fields Correct?", 32 + vbYesNo, "QC Dept.") = vbNo Then Exit Sub
If WorksheetFunction.CountIf(ws.Range("B2", ws.Cells(lRow, 1)), Me.ComboBox1.Value) > 0 Then
MsgBox "Delivery Data For Week No:" & ComboBox1.Value & vbCrLf & "Already exists Please Try Again.", vbCritical, "QC dept."
Exit Sub
End If
Thank you in advance for any Help!!