LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 586
Default Count non-zero values in a Array

I currently have the following code to count all the non-zero values in a
Array. Is there a cleaner way to do this?

Option Explicit

Dim PartRow(20) As Integer
Dim PartQty(20) as Single

Sub TestArray()

Dim i As Integer
Dim CounterRow As Integer
Dim CounterQty As Integer

For i = LBound(PartRow) To UBound(PartRow)
If PartRow(i) < 0 Then
CounterRow = CounterRow + 1
End If
Next i

For i = LBound(PartQty) To UBound(PartQty)
If PartQty(i) < 0 Then
CounterQty = CounterQty + 1
End If
Next i

If CounterRow = CounterQty Then
MsgBox "They equal; " & CounterRow
Else
MsgBox "They do NOT equal; " & CounterRow & " " & CounterQty
End If

End Sub

Thanks in Advance!
--
Cheers,
Ryan
 
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 values in array of data where no blanks in one column CW Excel Worksheet Functions 4 April 21st 10 12:43 PM
How to Reference an Array to Count Values? Mashuganah Excel Discussion (Misc queries) 6 December 4th 09 04:33 PM
Count certain values in numeric array avi Excel Programming 4 March 24th 08 08:02 AM
Count quanity of values in an Array Simon Shaw Excel Programming 3 July 12th 05 03:12 AM
Count how many different text values in an array. OVERLOAD Excel Worksheet Functions 3 April 14th 05 04:12 PM


All times are GMT +1. The time now is 11:51 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"