Insert A Blank Row Where A New Category Begins

geekette

Board Regular
Joined
Sep 12, 2006
Messages
120
I am trying to automate a spreadsheet. I've written code in VB to run an autofilter and copy and paste selected data into a new worksheet. I now need to insert subtotals in the new sheet where a name in a column changes.

So for example I have 5 rows of data where the source name = A. On the 6th row the source name = B. Inbetween these two rows I need to insert a subtotal to sum the data for source name A, and then continue down for source B, C, D etc...

Is this possible to do?

I will be so greatful for any help on this
 

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.

erik.van.geit

MrExcel MVP
Joined
Feb 1, 2003
Messages
17,832
Hi, geekette
Welcome to the Board !!!!!

Excel has a SUBTOTAL function
see menu DATA

kind regards,
Erik
 

geekette

Board Regular
Joined
Sep 12, 2006
Messages
120
Hi, I have another question about subtotaling. I used the method above and have included it within a macro which is great. Next I want to colour each subtotaled section in a different colour. Currently I do this manually.

Ideally I need to the first subtotalled section dark blue, the next light blue and alternate this until there are no more subtotals. Is there anyway I can do this?
 

Pekkavee

Well-known Member
Joined
May 25, 2004
Messages
1,218
You can use one color like this with conditional formatting.( Edit: Sorry this works only for "total" rows, and not the whole section. I didn't read you question right. )

If you have "Total" texts in column A put in A1 cell conditional formatting
with Formula is option

=ISNUMBER(FIND("Total",$A1,1))

and then select the color.

Then OK, OK.

Then copy your format to all cells

Pekka
:eek: :eek:
 

Forum statistics

Threads
1,136,647
Messages
5,676,983
Members
419,667
Latest member
MegEri

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
Top