How can I prevent duplicate record by validating two columns in my worksheet

genesix

New Member
Joined
Jul 9, 2024
Messages
3
Office Version
  1. 365
Platform
  1. Windows
I need to validate the following columns.

1. column 3 which is the employee name
2. column 5 which is the Login Date ( I need to validate the date if its not equal TODAY)



Dim lRow As Long
Dim ws As Worksheet
Set ws = Worksheets("Sheet1")
Application.ScreenUpdating = False
With Sheets("Sheet1")

If WorksheetFunction.CountIf(.Columns(3), ComboBox1) > 0 Then
MsgBox " You are Already Timed-in", vbCritical, "Employee Time-in"
Else
' Find emtpy row
lRow = ws.Cells(Rows.Count, 2).End(xlUp).Offset(1, 0).Row
 

Attachments

  • Sheet1.jpg
    Sheet1.jpg
    109.6 KB · Views: 13

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
Here is one way you can compare two dates (if you have it formatted as dates on the sheet)

VBA Code:
Sub compareDates()
    myDate = [A1].Value
    If DateDiff("d", myDate, Date) = 0 Then
        MsgBox "Date in A1 is today"
    Else
        MsgBox "Date in A1 is not today"
    End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,820
Messages
6,181,155
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top