Pivot Table Issues

How to Copy Column Widths Between PivotTables with VBA

Algirdas JasaitisAlgirdas Jasaitis Oct 23, 2026 869 views

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.

How to Copy Column Widths Between PivotTables Using VBA
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.
Before you start

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.

Solution 1Recommended

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.

1
Open the VBA Editor

Press ALT + F11 on your keyboard to launch the Visual Basic for Applications (VBA) Editor.

2
Insert a New Module

Click on Insert in the top menu and select Module to create a new blank script window.

3
Write the Copy Widths Script

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.

4
Run the Macro

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 a VBA Macro to Copy PivotTable Column Widths
Macro Adaptation: You may need to manually adjust the column indexes in the VBA script if your target PivotTables contain a vastly different number of columns compared to the source.
Manage PivotTables efficiently

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. 1. Open Your File: Launch WPS Spreadsheet and open your existing .xlsx file containing the PivotTables.
  2. 2. Access PivotTable Tools: Click anywhere inside the PivotTable to activate the dedicated PivotTable Tools ribbon at the top of the screen.
  3. 3. Adjust Formatting Options: Right-click the PivotTable, select Options, and disable automatic column resizing to maintain your preferred manual widths.
  4. 4. Save Smoothly: Save your document in the standard .xlsx format to ensure your formatting stays intact across different spreadsheet programs.
Fully compatible with Microsoft Excel formats (.xlsx, .xls) and PivotTable structures.Intuitive interface for drag-and-drop PivotTable creation and formatting.Lightweight and fast, handling large datasets without lagging.Free to use with comprehensive data analysis tools built-in.
microsoft office alternative - wps office

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.