Finding duplicates in rows of dates against the leave codes

jaysbp

New Member
Joined
Nov 17, 2022
Messages
7
Office Version
  1. 365
Platform
  1. Windows
Hi everyone, I am having difficulty in getting this code right. If you look at my screenshot, From columns L to T , I will have rows of data of leaves being applied by employees. They will have multiple rows of different leave types as they apply leave (from column L to T). From column W onwards, I will press the command button "Transfer Now" and it will spill out the dates horizontally without including weekends and holidays. I have gotten this code right.However, I need to write in a code to check from column W onwards only (in terms of row) to check the dates applied by the employee for different leave types on whether there is any duplicate date picked. For eg, if you can see in the screenshot, employee A has applied same dates like (22/12/2022) for VL (Cell X2) and SBL (Cell W3). I want the code to highlight the duplicate values for the respective employee. Can someone help me on this?

Screenshot.jpg

VBA Code:
Sub checkforrepeateddates()

'Declare All Variables.
Dim myCell As Range
Dim myRow As Integer
Dim myRange As Range
Dim myCol As Integer
Dim i As Integer
Dim ws As Worksheet: Set ws = ThisWorkbook.Worksheets("Lee Hyunsoo (3)")
    

With ws
myRow = Range(Cells(1, 1), Cells(1, 1).End(xlDown)).Count
myCol = Range(Cells(1, 1), Cells(1, 1).End(xlToRight)).Count


'Loop Each Row To Check Duplicate Values and Highlight cells.
For i = 2 To myRow
Set myRange = Range(Cells(i, 2), Cells(i, myCol))
For Each myCell In myRange
If WorksheetFunction.CountIf(myRange, myCell.Value) > 1 Then
myCell.Interior.ColorIndex = 3
End If
Next
Next
End With

End Sub
 
Thanks so much for attempting to help me on this matter. Yes, I am hoping someone can help me on this . I am trying to complete this by end of next week. Thanks!
 
Upvote 0

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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