Userform to check 2 textboxes for duplicate & date check

LadyAlina

New member
Joined
Mar 13, 2015
Messages
2
Reaction score
0
Points
0
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.


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

Code:
Private Sub reportdate_Change()
Dim d1 As Date
Dim d2 As Date
d1 = 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
 
Last edited by a moderator:
Code:
[COLOR=#333333]Private Sub reportdate_Change()[/COLOR]
Dim d1 As Date
Dim d2 As Date
d1 = Date
d2 = CDate(textbox2.Value)
If d2 < d1 Then
MsgBox "Error! Please change date"
End If 
[COLOR=#333333]End Sub[/COLOR]
 
Back
Top