Hi- I have a UDF in one of my workbooks that is called when it shouldn't be. I don't think it is causing any errors (yet), but it is def slowing down my macro. Any thoughts are appreciated. Here is the UDF:
It is hard to pinpoint when/why the UDF is running, but here is an example:
When I hit the yellow text, I jump in to the UDF. anybody else seen this before?
Code:
Public Function CFwd(dtEnd As Date)
'-- Return the last working day of the current month
Dim Searching As Boolean
Searching = True
CFwd = DateSerial(Year(dtEnd), Month(dtEnd) + 1, 0) '-- Start at the last day of the month
Do While Searching
If Weekday(CFwd, vbMonday) > 5 Then
'-- Weekend day, back up a day
CFwd = CFwd - 1
Else
'-- If you have a Holiday Table then enable the next IF...Else
' If Weekday(CFwd, vbMonday) > 5 Or _
Not IsNull(DLookup("[HoliDate]", "tblHolidays", _
"[HoliDate] = " & Format(CFwd, "\#mm\/dd\/yyyy\#;;;\N\u\l\l"))) Then
'-- The above Format of CFwd works with US or UK dates!
' CFwd = CFwd - 1
' Else
'-- The search is over
Searching = False
End If
Loop
End Function
It is hard to pinpoint when/why the UDF is running, but here is an example:
Code:
LR = Cells(Rows.Count, "R").End(xlUp).Row
''clear zeros
For i = LR To 1 Step -1
If Cells(i, "R").Value = 0 Then
[COLOR=yellow] Range(Cells(i, "Q"), Cells(i, "T")).Delete shift:=xlUp
[/COLOR] End If
Next i
When I hit the yellow text, I jump in to the UDF. anybody else seen this before?