How to Copy Column Widths Between PivotTables with VBA
Question details
The user needs to copy column widths from a source PivotTable to other PivotTables, but the standard Paste Special feature is blocked by the software.

- Product
- Spreadsheet software
- Device & OS
- not provided
- Scenario
- Standardizing column widths across multiple PivotTables on the same worksheet that share common columns but contain different filters or data subsets.
- Observed behavior
- Using Paste Special > Column Widths displays an error stating that the change would affect a PivotTable, preventing the user from applying consistent widths.
Ensure that the Developer tab is enabled in your spreadsheet program so you can access the VBA Editor, and note down the exact name of your source PivotTable.
Use a VBA Macro to Copy PivotTable Column Widths
The most reliable method to bypass the standard Paste Special restriction is using a VBA macro to loop through and apply the source PivotTable's column widths to the others.
A VBA script can directly target the TableRange1 property of PivotTables, ensuring that corresponding columns receive the exact ColumnWidth value from the source table without triggering overlap errors.
Press ALT + F11 on your keyboard to launch the Visual Basic for Applications (VBA) Editor.
Click on Insert in the top menu and select Module to create a new blank script window.
Create a macro that references your source PivotTable (e.g., 'PivotTable1'). Use a 'For Each' loop to iterate through all other PivotTables on the active worksheet, mapping and applying the ColumnWidth from the source to the target's TableRange1 columns.
Close the VBA editor or press F5 while inside the macro to run it. The column widths will automatically update across the active sheet.

Use Paste Special with a Values Workaround
If you are unable to use VBA, you can paste the PivotTable as values elsewhere and then copy the column widths from that static range.
Disable Automatic Autofit on Update
Prevent the software from resetting your manually adjusted column widths every time the PivotTable data refreshes.
Manage and Format PivotTables Easily with WPS Office
WPS Spreadsheet offers robust support for PivotTables, advanced formatting, and excellent compatibility with Microsoft Excel files, allowing you to organize and analyze data seamlessly.
- 1. Open Your File: Launch WPS Spreadsheet and open your existing .xlsx file containing the PivotTables.
- 2. Access PivotTable Tools: Click anywhere inside the PivotTable to activate the dedicated PivotTable Tools ribbon at the top of the screen.
- 3. Adjust Formatting Options: Right-click the PivotTable, select Options, and disable automatic column resizing to maintain your preferred manual widths.
- 4. Save Smoothly: Save your document in the standard .xlsx format to ensure your formatting stays intact across different spreadsheet programs.

Frequently Asked Questions
Why does the software block Paste Special > Column Widths for PivotTables?
Spreadsheet software restricts direct structural formatting changes that might overlap or conflict with the dynamic, auto-expanding nature of PivotTables. This is why it triggers an error stating the action would affect the PivotTable structure.
How do I stop my PivotTable column widths from changing when I refresh the data?
You can lock the widths by right-clicking the PivotTable, selecting PivotTable Options, navigating to the Layout & Format tab, and unchecking the 'Autofit column widths on update' option.
Do VBA macros for PivotTables work identically in alternative spreadsheet software?
Most standard VBA macros work similarly in professional software like WPS Office, which supports VBA in specific editions. However, highly complex PivotTable object references may occasionally require minor syntax adjustments depending on the specific macro environment.




