Pivot table - row height subtotal

Hidden Dan

Board Regular
Joined
Dec 7, 2016
Messages
63
Hello friends,

I'm rebuilding an extensive spreadsheet containing a lot of macro's. To make maintenance a lot easier I decided to create a pivot table. This works fine, but it doesn't look the way I like.

Main concerns are related to 'Subtotals'. They do not show well and for a static sheet I would change 'Row height' to create additional white space. But as a pivot table is dynamic, this doesn't work.

So my question is, is there a VBA script available that automatically changes row height from 15 to 30 once it notices 'Subtotal' ? There may be at least 4 or 5 'Subtotals' in the pivot table.

I already make use of an 'update pivot table' macro so it may integrated with this one.


Thanks, Dan
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
Code:
Sub FormatSubtotalRow()
Dim LastRow As Long
Dim i As Long
With ActiveSheet
    LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
    For i = 2 To LastRow
        If LCase(Left(Range("A" & i), 8)) = "subtotal" Then Rows(i).RowHeight = 30
    Next i
End With
End Sub
 
Upvote 0
Thanks for the code and my huble apologies for slow reacting. I was unexpected off last week.

I tried the code but was unable to get it working. My pivot table starts at C26 so 'Total' can be found at column C and any 'Subtotal' at columns D and E.

Could this be of any influence to the code ?


Dan
 
Upvote 0
yes
"A" refers to column A
you have to change that
2 To LastRow means that the macro runs from row 2
you have to change that
If LCase(Left(Range("A" & i), 8)) = "subtotal" Then Rows(i).RowHeight = 30 looks only after one column
for more columns copy the line or use OR
 
Upvote 0

Forum statistics

Threads
1,223,904
Messages
6,175,295
Members
452,632
Latest member
jladair

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