Forum Discussion

sTambux05's avatar
sTambux05
Copper Contributor
Jan 30, 2024

Row height of pivot table

Hello to all,
I have a file with a pivot table, and when I update the row height and content font size varies automatically despite my attempts to reformat cells. How can I solve the problem?
Thank you

  • For precise control over row heights and font sizes, you can use VBA (Visual Basic for Applications) to set these properties. Here’s a basic example of how to set row height and font size:
    vba
    Copy code
    Sub AdjustPivotFormatting()
    Dim ws As Worksheet
    Set ws = ThisWorkbook.Sheets("YourSheetName")
    With ws.PivotTables("YourPivotTableName")
    .RowAxisLayout xlTabularRow
    .RowFields(1).DataRange.Rows.RowHeight = 20
    .DataBodyRange.Font.Size = 12
    End With
    End Sub
    Adjust "YourSheetName" and "YourPivotTableName" accordingly.

Resources