VBA & Macro Problems

How to Convert Column Headers and Values into a List in Excel

Huma Ashraf ChHuma Ashraf Ch Oct 26, 2026 868 views

Question details

The user needs to convert a wide dataset (spanning columns B through D) into a two-column list by repeating each column's header beside its respective values.

How to Convert Column Headers and Values into a List Using VBA or Power Query
Product
Spreadsheet
Device & OS
not provided
Scenario
Reorganizing or unpivoting a dataset so that multi-column data is flattened into Attribute-Value pairs for easier analysis or database import.
Observed behavior
The goal state is a flat, vertical list where each data point is paired with its original column header, replacing the original wide format.
Before you start

Ensure you have backed up your original dataset before running macros or data transformations. If using VBA, verify that the Developer tab is enabled in your ribbon.

Solution 1Recommended

Use Power Query to Unpivot Columns

The easiest, code-free method to convert columns into a list is using the 'Unpivot' feature in Power Query, which dynamically transforms wide data into key-value pairs.

Power Query is highly recommended for this task because it handles dynamic data ranges automatically and requires no programming knowledge.

1
Load Data into Power Query

Select your data range, navigate to the Data tab, and click 'From Table/Range' to open the Power Query Editor.

2
Add an Index Column

Go to the Add Column tab and click 'Index Column'. This creates a unique identifier for your rows, helping keep data organized during the transformation.

3
Unpivot Other Columns

Right-click the newly created Index column header and select 'Unpivot Other Columns'. This action transforms the rest of the columns into Attribute (header) and Value pairs.

4
Load the Transformed Data

Rename the newly generated columns as needed. Finally, go to the Home tab and click 'Close & Load' to output the two-column list back into your spreadsheet.

Use Power Query to Unpivot Columns
Dynamic Updates: If you add more data to your original table later, simply right-click the Power Query result table and select Refresh to update the unpivoted list.

Easily Manage and Unpivot Data with WPS Spreadsheet

WPS Office provides robust spreadsheet tools including full VBA compatibility. Whether you prefer running macros or using built-in features, reorganizing complex data layouts is fast and straightforward.

  1. 1. Open your file in WPS Spreadsheet: Launch WPS Office and open the workbook containing the wide data table you want to unpivot.
  2. 2. Access the VBA tools: Navigate to the Developer tab to open the VBA Editor and insert your transformation macro.
  3. 3. Execute the transformation: Run the code to instantly generate your new two-column list without affecting the original data layout.
Fully compatible with Microsoft Excel formats (.xlsx) and macros (.xlsm)Comprehensive VBA macro support for advanced data manipulationLightweight and free alternative for complex data tasksFamiliar interface with a seamless transition and no learning curve
microsoft office alternative - wps office

Frequently Asked Questions

Can I convert columns to a list without VBA?

Yes, using the Power Query 'Unpivot' feature is an excellent, no-code alternative that dynamically transforms wide columns into a clean two-column list.

What happens to blank cells when unpivoting?

By default, Power Query ignores null or blank cells during the unpivot process, ensuring your resulting list only contains rows with actual data values.

Why is my VBA macro not running?

Ensure that your file is saved in a macro-enabled format (.xlsm) and that you have enabled macros in your Trust Center or Developer tab security settings.