Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.misc
|
|||
|
|||
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 |
#2
Posted to microsoft.public.excel.misc
|
|||
|
|||
WorksheetFunction not working correctly
I'd try qualifying the ranges in the countif() expression.
Maybe... Worksheets(wsheetName).Range("A19").Value = Application.WorksheetFunction _ .CountIf(Worksheets(wsheetName).Range("E2:E16"), "Completed") Or whatever worksheet owns that range("E2:E16") Ayo wrote: 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 -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
VLookup is not working correctly | Excel Worksheet Functions | |||
Hyperlink not working correctly | Excel Discussion (Misc queries) | |||
vlookup isn't working correctly? | Excel Discussion (Misc queries) | |||
Autofilter not working correctly... | Excel Discussion (Misc queries) | |||
Cursor not working correctly | Excel Discussion (Misc queries) |