Im trying to write my own date adjustment function in VBA. NOTE NBD=next business day , PBD= previous business day and MF= modified following
Public Function DateAdjust(d1 As Double, rule As String, ZARHols As Range) As Double
Dim r, c, y As Double
r = ZARHols.Rows.Count
c = ZARHols.Columns.Count
y = d1

Select Case rule
Case "NBD"
Dim i As Integer
For i = 1 To r
If y = ZARHols(i, 1) Then
y = y + 1
End If
Next i
DateAdjust = y
Case "PBD"
For i = 1 To r
If y = ZARHols(i, 1) Then
y = y - 1
End If
Next i
DateAdjust = y

Case "MF"
For i = 1 To r
Do While Month(y) = Month(d1)
If y = ZARHols(i, 1) Then
y = y + 1
End If
DateAdjust = y
Loop
Do While Month(y) > Month(d1)
If y = ZARHols(i, 1) Then
y = y - 1
End If
Loop
Next i
DateAdjust = y

End Select
End Function
Sub Random()
Dim ZARHols As Range
Set ZARHols = Worksheets("1.Date Generation").Range("L42:L644")
End Sub