Home |
Search |
Today's Posts |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
If your arrays were variant arrays then you could do something like this:
Sub test() Dim i As Long Dim arr(0 To 3) For i = 1 To 3 arr(i) = i Next i MsgBox Application.WorksheetFunction.CountA(arr) End Sub It would then leave out the empty array elements. As you have declared as Integer and Single there always will be a zero in the elements that have not been set, so the above won't work. What is wrong with the code you got? It looks fine to me. RBS "RyanH" wrote in message ... 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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Count values in array of data where no blanks in one column | Excel Worksheet Functions | |||
How to Reference an Array to Count Values? | Excel Discussion (Misc queries) | |||
Count certain values in numeric array | Excel Programming | |||
Count quanity of values in an Array | Excel Programming | |||
Count how many different text values in an array. | Excel Worksheet Functions |