Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
Ayo Ayo is offline
external usenet poster
 
Posts: 489
Default 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   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
VLookup is not working correctly Eric @ BP-EVV Excel Worksheet Functions 3 July 18th 08 12:24 AM
Hyperlink not working correctly DonnaO Excel Discussion (Misc queries) 0 November 20th 07 10:45 AM
vlookup isn't working correctly? Dave F Excel Discussion (Misc queries) 2 October 14th 06 04:27 AM
Autofilter not working correctly... Emily Excel Discussion (Misc queries) 0 January 11th 06 10:37 PM
Cursor not working correctly LSOT Excel Discussion (Misc queries) 4 November 1st 05 04:45 PM


All times are GMT +1. The time now is 04:56 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"