johnabrosky
New Member
- Joined
- May 17, 2018
- Messages
- 1
Hello,
I have two tabs in by spreadsheet. "Report" and "Holidays". In the first tab I have data and one column contains dates (format: mm/dd/yyyy).
Also, in column A of Holidays tab I have listed several dates.
I would like to delete all rows from tab Report which are holidays listed in the second tab or weekend (Saturday, Sunday).
I found one code that works for holidays, but I don't understand how it works. Could someone be as kind to explain it in simplest words possible? Thank you in advance!
I have two tabs in by spreadsheet. "Report" and "Holidays". In the first tab I have data and one column contains dates (format: mm/dd/yyyy).
Also, in column A of Holidays tab I have listed several dates.
I would like to delete all rows from tab Report which are holidays listed in the second tab or weekend (Saturday, Sunday).
I found one code that works for holidays, but I don't understand how it works. Could someone be as kind to explain it in simplest words possible? Thank you in advance!
Code:
Sub Holidays()
Dim d As Object, e, rws&, cls&, i&, j&
Set d = CreateObject("scripting.dictionary")
For Each e In Sheets("Holidays").Range("A1").CurrentRegion
d(e.Value) = 1
Next e
Sheets("ANA").Activate
rws = Cells.Find("*", after:=[a1], searchorder:=xlByRows, _
searchdirection:=xlPrevious).Row
cls = Cells.Find("*", after:=[a1], searchorder:=xlByColumns, _
searchdirection:=xlPrevious).Column
For i = rws To 1 Step -1
For j = 1 To cls
If d(Range("A1").Resize(rws, cls)(i, j).Value) = 1 Then _
Cells.Rows(i).Delete: Exit For
Next j, i
End Sub