R
RyanH
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!
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!