PDA

View Full Version : Userform to check 2 textboxes for duplicate & date check



LadyAlina
03-24-2015, 03:06 AM
Hi,


I have a userform all set and ready to use but I'm facing a problem with it. The problem is I want the submit button to check if the entry has already been made by checking 2 textboxes (Textbox1 & Textbox2) with the columns in sheet (Column A & D). If both the textboxes' enry matches with the existing data then it should replace the row after giving a message else add it to next empty row. I used one code I got from this forum but it didnot work for me nor does it gives an option of replacing existing row with same data and I don't know how to modify it..


There is one more thing I want the xperts help with that is I want to check the date entered in textbox2 if its previous then give error message (Basically it should not allow entry in previous date). I do have the code for this one but it is rejecting all dates of 2015 (I guess its taking format as mm/dd/yy however it should be dd/mm/yy.


Dim search_a, search_b As String'checks for a duplicate competitor entrysearch_a = textbox1.Valuesearch_b = textbox2.Value
If Evaluate("sum((A2:A=" & search_a & ")*(D2:D=" & search_b & "))>=1") Then
MsgBox "duplicate"

End If


Private Sub reportdate_Change()Dim d1 As DateDim d2 As Dated1 = Date
d2 = (textbox2.Value)
If d2 < d1 Then
MsgBox "Error! Please change date"
End If
End Sub

I checked entire forum all I got was check duplicate only with 1 textbox. Any help will be greatly appreciated. Thanks in adavnce

Bob Phillips
03-24-2015, 09:28 AM
Cross-posted at ExcelGuru http://www.excelguru.ca/forums/showthread.php?4277-Userform-to-check-2-textboxes-for-duplicate-amp-date-check

Tom Jones
03-25-2015, 12:39 AM
Cross-posted here also:

Userform to check 2 textboxes for duplicate & date check (http://www.mrexcel.com/forum/excel-questions/844279-userform-check-2-textboxes-duplicate-date-check.html) in MrExcel forum

Userform to check 2 textboxes for duplicate & date check (http://www.ozgrid.com/forum/showthread.php?t=193806) in Ozgrid forum (was banned from previosly warned)