Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Getting a count of formula results only.


Hi Everybody,
I've googled for an hour and must not be coming up with a meaningfu
search phrase. Lots of stuff on counts of all kinds but not what I'
looking for. Please help.
I use the following bit of code in a lot of different Subroutines t
count the number of entries in a range.

Entries = Excel.WorksheetFunction.CountA(Wks2.Range("CABSDTO PS"))

But now I find the need to obtain the a count from a range tha
contains formulas, so my count value ends up being the entire range (
of cells in range) because the COUNTA function treats the formula i
the cell as something to count.
What I need is a count of the cells in this range where the formula ha
calculated a value other than 0. Thanks in advance for any help.

Here is my current Code

Private Sub ImportCAtoSTD_Click()
Dim Wks2 As Worksheet
Dim Wks3 As Worksheet
Dim CopyRow As Long
Dim Entries As Long
Dim i As Long
Dim Cnt As Integer
Dim Cnt2 As Long
Dim Cnt3 As Long
Dim Msg As Integer
Dim Response As Integer
Dim N As Double

Msg = MsgBox("Is the Cabinet Area Takeoff complete and" & (Chr(13))
_
"cabinets with tops are indicated as such by" & (Chr(13)) & _
"a dimension in the Cabinet Database?", vbYesNo + vbQuestion, "Impor
Room # & Top SF Cabinets")
If Msg = 6 Then
Application.ScreenUpdating = False

Set Wks2 = Worksheets("Cabinet Areas")
Set Wks3 = Worksheets("Slabs-Tops-Decks")
'Clear the worksheet prior to importing new information
Wks3.Range("STDImportRange").ClearContents
Cnt = 0
Cnt2 = 0
Cnt3 = 0
'Set CopyRow to numerical value of first row to start copy process
CopyRow = 3
Entries = Excel.WorksheetFunction.CountA(Wks2.Range("CABSDTO PS"))
Cnt2 = Wks3.Range("RoomSTD").Rows.Count
Cnt3 = Entries - Cnt2
For i = 3 To Entries + 1000
N = Wks2.Cells(i, 9).Value
If N < 0 Then Cnt = Cnt + 1
If Cnt Cnt2 Then
MsgBox "You are attempting to import more records than you hav
rows." _
& (Chr(13)) & "Please go to the bottom of the Entry Area an
use the blue button" & (Chr(13)) _
& "to add " & Cnt3 & " additional Rows. Then hit the Impor
button again.", vbOKOnly + vbCritical, "Not enough Rows"
If Response = 1 Or 2 Then
Wks3.Range("STDImportRange").ClearContents
Exit Sub
End If
ElseIf N < 0 And Cnt <= Cnt2 Then
With Wks3
.Unprotect ("geekk")
.Cells(CopyRow, 1).Value = Wks2.Cells(i, 1).Value 'Room #
.Cells(CopyRow, 7).Value = Wks2.Cells(i, 4).Value 'LF Cabs
.Cells(CopyRow, 8).Value = Wks2.Cells(i, 9).Value 'to
depth
.Cells(CopyRow, 13).Value = Wks2.Cells(i, 10).Value 'to
SF
.Cells(CopyRow, 14).Value = Wks2.Cells(i, 3).Value 'ca
type
.Protect ("geekk"), DrawingObjects:=True, Contents:=True
Scenarios:=True
End With
CopyRow = CopyRow + 1

End If
Next i

Wks3.Range("C3").Activate
Application.ScreenUpdating = True
End If
If Msg = 7 Then
Exit Sub

End If
End Su

--
Case

-----------------------------------------------------------------------
Casey's Profile: http://www.excelforum.com/member.php...nfo&userid=454
View this thread: http://www.excelforum.com/showthread.php?threadid=47184

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Getting a count of formula results only.

Entries = Excel.WorksheetFunction.CountIF(Wks2.Range("CABSDT OPS"),"<0")

--
Regards,
Tom Ogilvy

"Casey" wrote in
message ...

Hi Everybody,
I've googled for an hour and must not be coming up with a meaningful
search phrase. Lots of stuff on counts of all kinds but not what I'm
looking for. Please help.
I use the following bit of code in a lot of different Subroutines to
count the number of entries in a range.

Entries = Excel.WorksheetFunction.CountA(Wks2.Range("CABSDTO PS"))

But now I find the need to obtain the a count from a range that
contains formulas, so my count value ends up being the entire range (#
of cells in range) because the COUNTA function treats the formula in
the cell as something to count.
What I need is a count of the cells in this range where the formula has
calculated a value other than 0. Thanks in advance for any help.

Here is my current Code

Private Sub ImportCAtoSTD_Click()
Dim Wks2 As Worksheet
Dim Wks3 As Worksheet
Dim CopyRow As Long
Dim Entries As Long
Dim i As Long
Dim Cnt As Integer
Dim Cnt2 As Long
Dim Cnt3 As Long
Dim Msg As Integer
Dim Response As Integer
Dim N As Double

Msg = MsgBox("Is the Cabinet Area Takeoff complete and" & (Chr(13)) &
_
"cabinets with tops are indicated as such by" & (Chr(13)) & _
"a dimension in the Cabinet Database?", vbYesNo + vbQuestion, "Import
Room # & Top SF Cabinets")
If Msg = 6 Then
Application.ScreenUpdating = False

Set Wks2 = Worksheets("Cabinet Areas")
Set Wks3 = Worksheets("Slabs-Tops-Decks")
'Clear the worksheet prior to importing new information
Wks3.Range("STDImportRange").ClearContents
Cnt = 0
Cnt2 = 0
Cnt3 = 0
'Set CopyRow to numerical value of first row to start copy process
CopyRow = 3
Entries = Excel.WorksheetFunction.CountA(Wks2.Range("CABSDTO PS"))
Cnt2 = Wks3.Range("RoomSTD").Rows.Count
Cnt3 = Entries - Cnt2
For i = 3 To Entries + 1000
N = Wks2.Cells(i, 9).Value
If N < 0 Then Cnt = Cnt + 1
If Cnt Cnt2 Then
MsgBox "You are attempting to import more records than you have
rows." _
& (Chr(13)) & "Please go to the bottom of the Entry Area and
use the blue button" & (Chr(13)) _
& "to add " & Cnt3 & " additional Rows. Then hit the Import
button again.", vbOKOnly + vbCritical, "Not enough Rows"
If Response = 1 Or 2 Then
Wks3.Range("STDImportRange").ClearContents
Exit Sub
End If
ElseIf N < 0 And Cnt <= Cnt2 Then
With Wks3
Unprotect ("geekk")
Cells(CopyRow, 1).Value = Wks2.Cells(i, 1).Value 'Room #
Cells(CopyRow, 7).Value = Wks2.Cells(i, 4).Value 'LF Cabs
Cells(CopyRow, 8).Value = Wks2.Cells(i, 9).Value 'top
depth
Cells(CopyRow, 13).Value = Wks2.Cells(i, 10).Value 'top
SF
Cells(CopyRow, 14).Value = Wks2.Cells(i, 3).Value 'cab
type
Protect ("geekk"), DrawingObjects:=True, Contents:=True,
Scenarios:=True
End With
CopyRow = CopyRow + 1

End If
Next i

Wks3.Range("C3").Activate
Application.ScreenUpdating = True
End If
If Msg = 7 Then
Exit Sub

End If
End Sub


--
Casey


------------------------------------------------------------------------
Casey's Profile:

http://www.excelforum.com/member.php...fo&userid=4545
View this thread: http://www.excelforum.com/showthread...hreadid=471842



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Getting a count of formula results only.


Tom,
Worked perfectly as all your help seems to. I keep hoping that this VB
stuff will click with me. Here I am using a worksheet function, famila
ground, and I overlook the obvious choices. I hesitate to pos
sometimes, cause my code looks like, I know sorta, what I'm doing, bu
it's just inelegant, cobbled together bits from here and there plus
lot of google searches. Thanks so much for the help Tom

--
Case

-----------------------------------------------------------------------
Casey's Profile: http://www.excelforum.com/member.php...nfo&userid=454
View this thread: http://www.excelforum.com/showthread.php?threadid=47184

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
Count only visible formula results Joe M. Excel Discussion (Misc queries) 2 September 23rd 08 02:21 PM
Count only visible results of formula Joe M. Excel Discussion (Misc queries) 3 September 4th 08 04:03 PM
How can I count the results ??? Mark Allen Excel Worksheet Functions 4 November 23rd 06 03:59 PM
array formula count results of two tests windsurferLA Excel Worksheet Functions 2 July 26th 06 12:33 AM
Count of results in AutoFilter andrew Excel Programming 3 October 2nd 04 12:45 AM


All times are GMT +1. The time now is 10:16 PM.

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

About Us

"It's about Microsoft Excel"