Subtotal Macro: error and auto format

XLstooge

New Member
Joined
Jul 23, 2009
Messages
10
Hi All,
I am trying to create macro for subtotaling rows:

Application.CutCopyMode = False
rw = Range(Range("A1"), Range("A1").EndxlDown)).Rows.Count
col = 16
Range("A1").Resize(rw, col).Select
Selection.subtotal GroupBy:=6, Function:=xlSum, TotalList:=Array(15, 16), _
Replace:=True, PageBreaks:=False, SummaryBelowData:=True

My question are:
1. When there is only header and no records on sheet the macro return error message :
errorihv.jpg


2. What is this "GroupBy:=6" syntax does? What if I change the number to 10?

3. Is there anyway to make the subtotal cels (starting from leftmost to right of the table where it contain subtotal amount) to automatically formatted in specific color, font, style?

Pardon me for asking so many questions. This thing is so new to me.
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.

Forum statistics

Threads
1,214,833
Messages
6,121,868
Members
449,053
Latest member
Mesh

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