I have a Master.xlsx. I have a two variables startd and endd that define date range I should be storing in my dictionary.
I have the list of holidays I am trying to remove from the dictionary in a separate worksheet.
Set hld = Sheet2.Range("A2:A7")
....
....
Dim WDdict As New Scripting.dictionary
For n = startd To endd: WDdict(n) = 1: Next
For Each hd In hld
If hd > 0 Then hd = DateValue(hd): If WDdict.Exists(hd) Then WDdict.Remove (hd)
Next
"Base" is the name of one of the worksheets. This "Base" sheet has two key columns - Email and Date of Joining (DOJ)
EmlsrcA = Application.Transpose(src.Sheets("Base").Range("A2:A" & rowsn))
DojsrcA = Application.Transpose(src.Sheets("Base").Range("G2:G" & rowsn))
What I want to do
If DOJ value for every row is after / later than the startd (input parameter) then remove every date between startd and DOJ from the dictionary.
I tried
For Each emls In EmlsrcA 'each line in email in base page
Dim WDdictrs As New Scripting.dictionary
For Each elm In WDdict: WDdictrs(elm) = 1: Next
remove dates before doj
dj = 0
If DojsrcA(dj) > startd Then
dj = dj + 1
For n = startd To DojsrcA(dj):
If WDdictrs.Exists(n) Then WDdictrs.Remove (n) Else WDdictrs(n) = 1
Next
End If
It throws
subscript out of range
on If DojsrcA(dj) > startd Then
.