count cells in union greater than zero

ThomasOES

Board Regular
Joined
Aug 29, 2017
Messages
174
Is it possible to count the cells in a union that are greater than zero
the cells aren't connected
VBA Code:
For index = 0 To cs_selstn.stanbox.ListCount - 1
    If cs_selstn.stanbox.Selected(index) Then
    Set seqcar = canlis.Find(cs_selstn.stanbox.List(index), , , 1).Offset(, 1)
    GoTo nexsta
    End If
Next
nexsta:
For index = index To cs_selstn.stanbox.ListCount - 1
    If cs_selstn.stanbox.Selected(index) Then
    Set nexcar = canlis.Find(cs_selstn.stanbox.List(index), , , 1).Offset(, 1)
    Set seqcar = Application.Union(seqcar, nexcar)
    End If
Next
I use this code to select numeric values based on the names selected in a list box
so the code loops and builds the range based on each name selected
I end up with several cells that aren't connected
I would like to acquire a count of the numeric values greater than zero
I tried
Code:
m = WorksheetFunction.CountIf(seqcar, ">0")
but no luck

Thanks
Tom
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
This works, but feels clunky
VBA Code:
m = 0
For Each cell In seqcar
If cell.Value > 0 Then
m = m + 1
End If
Next cell
MsgBox m
 
Upvote 0

Forum statistics

Threads
1,215,061
Messages
6,122,921
Members
449,094
Latest member
teemeren

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top