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

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
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,224,823
Messages
6,181,179
Members
453,021
Latest member
Justyna P

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