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

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
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,223,958
Messages
6,175,629
Members
452,661
Latest member
Nonhle

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