Hi everyone
Can someone tell me why the error handler is being invoke when there is no error with this code. I would very much appreciate any input
Thanks
Denis
Code
Sub compte1(newSheet1, takemonth, wname1, first_blue_cell, first_gray_cell)
Application.DisplayAlerts = False
On Error GoTo ErrHandler:
nyear = Right(newSheet1, 4)
svalue = takemonth - 1 & "/" & nyear
check_svalue = Len(svalue)
If check_svalue = 6 Then
svalue = "0" & svalue
End If
'MsgBox svalue
Sheets("Stats_Holiday").Select
Cells.Find(What:=nyear, After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
False).Activate
wyear = Left$(ActiveCell.Address(0, 0), (ActiveCell.Column < 27) + 2)
rowcount = Sheets("Stats_Holiday").UsedRange.Rows.Count
For I = 2 To rowcount
Sheets("Stats_Holiday").Select
Range(wyear & I).Select
cval = ActiveCell.Value
cval1 = Right(cval, 7)
If cval1 = svalue Then
Call stats_holiday(newSheet1, takemonth, wname1, first_blue_cell, first_gray_cell, cval)
End If
Next
Sheets(newSheet1).Select
ErrHandler:
MsgBox ("You must update the Stats_Holiday worksheet to reflect this year stat's holiday")
Sheets(newSheet1).Delete
Application.DisplayAlerts = True
Call put_orange
End Sub
Display More