Count and add cells in column after last occurrence of series

lefty365

New Member
Joined
Jan 5, 2015
Messages
19
Hello,
I have a spreadsheet with lots of columns. Some columns need items counted and some need items added. I'm hoping someone can help me with code to count and add cells in a column after the last occurrence of a series of items.

Let me explain with an example. The code would start with Col A and search down to find the first blank row. It would count the number of items in the series prior to the blank row. In this case, there are 4 blue items. The next series down is red. The blank row would be found and the red items would be counted. There are 9. It would continue to the last row. Col B would be next with the items before the first blank row being added. The total is 11,329. The next blank row would be found and the previous items added. This would equal 24,998. The code would continue to the last row. I hope this makes sense.

Thank you,

Mark


Col A Col B
blue2,000
blue2340
blue3500
blue3489
red2,000
red2340
red3500
red3489
red2,000
red2340
red3500
red3489
red2340
green2,000
green2340
green3500
green3489
green2340
green3500
brown2,000
brown2340
brown3500
yellow2,000
yellow2340
yellow3500
yellow3489
yellow2340
yellow3500

<tbody>
</tbody>
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
Why don't you just turn your data into a Pivot Table?

Add Color column to the rows section, then add the column b as a sum of the values, and add column b again as a count of the values. Then you could just filter out the blanks.
 
Upvote 0
Thank you very much for your reply. I appreciate it. You opened my eyes to a pivot table solution. I've been working with it and I think its doable. Thank you very much. I wouldn't have tried without your suggestion.

Sincerely,

Mark
 
Upvote 0
I realized why pivot tables are a challenge. I need to run the report regularly and I want to compile it with the least amount of work. Pivot tables will change based on the information changing. The fields won't be consistent month to month. I may be wrong there but I don't know how to do that.

Thanks
 
Upvote 0

Forum statistics

Threads
1,215,054
Messages
6,122,895
Members
449,097
Latest member
dbomb1414

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