WorksheetFunction not working correctly
I using the following code in one of my worksheets. It is show a very
perculiar result. When I run it normally, form a button on the worksheet, I
get "0" for all my result. Which means the right part of the equations are
not working correctly. But when I run it in debug mode, that is press "F8" to
step-through the code, everything works fine. I get the correct values.
Any ideas why it is doing these?
Thanks.
If Worksheets(wsheetName).Range("E2") < "" Then
Worksheets(wsheetName).Range("A19").Value =
Application.WorksheetFunction.CountIf(Range("E2:E1 6"), "Completed")
Worksheets(wsheetName).Range("D19") =
Application.WorksheetFunction.CountIf(Range("E2:E1 6"), "In-Progress")
End If
If Worksheets(wsheetName).Range("K2") < "" Then
Worksheets(wsheetName).Range("G19").Value =
Application.WorksheetFunction.CountIf(Range("K2:K1 6"), "Completed")
Worksheets(wsheetName).Range("J19") =
Application.WorksheetFunction.CountIf(Range("K2:K1 6"), "In-Progress")
End If
If Worksheets(wsheetName).Range("E24") < "" Then
Worksheets(wsheetName).Range("A41").Value =
Application.WorksheetFunction.CountIf(Range("E24:E 38"), "Completed")
Worksheets(wsheetName).Range("D41") =
Application.WorksheetFunction.CountIf(Range("E24:E 38"), "In-Progress")
End If
If Worksheets(wsheetName).Range("K24") < "" Then
Worksheets(wsheetName).Range("G41").Value =
Application.WorksheetFunction.CountIf(Range("K24:K 38"), "Completed")
Worksheets(wsheetName).Range("J41") =
Application.WorksheetFunction.CountIf(Range("K24:K 38"), "In-Progress")
End If
|