Count continuous cells as one in a column

ksillas

New Member
Joined
Jun 29, 2017
Messages
15
Hello,

I need to count "grouped" cells with values as one. Column "I" has bunch of 1's and 0's if it was on or off. I already deleted all the 0's and was left with 1's and empty cells in between. For example:

[TABLE="class: grid, width: 200, align: center"]
<tbody>[TR]
[TD]1[/TD]
[/TR]
[TR]
[TD]1[/TD]
[/TR]
[TR]
[TD]1[/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD]1[/TD]
[/TR]
[TR]
[TD]1[/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD]1[/TD]
[/TR]
[TR]
[TD]1[/TD]
[/TR]
[TR]
[TD]1[/TD]
[/TR]
</tbody>[/TABLE]

This has 3 "groups" so the end count would be 3.

To do it manually I would press CTRL+Down Arrow twice (once to reach the first cell with content, the second one to reach the last cell with content) and that would count as 1 "group."


If you guys need more information I'm glad to explain further. The excel file (per day) contains around 200K rows , it's like a log file that records every 300ish milliseconds..
 
Last edited:

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
If the cells contain values rather than formulae try
Code:
Sub ksillas()
   MsgBox Range("I:I").SpecialCells(xlConstants).Areas.Count
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,889
Messages
6,175,226
Members
452,620
Latest member
dsubash

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