VBA & Macro Problems

How to Sort Every Excel Column Independently from Lowest to Highest in WPS Office

Rana GarciaRana Garcia Nov 13, 2026 870 views

Question details

The user needs to sort each column of a large worksheet range independently from lowest to highest without rearranging values in other columns.

How to Sort Every Excel Column Independently from Lowest to Highest in WPS Office
Product
WPS Office Spreadsheets
Device & OS
not provided
Scenario
A normal sort moves complete rows; the user wants only each individual column reordered from top to bottom.
Observed behavior
A standard Excel sort rearranges complete rows, so it cannot independently sort every column.
Before you start

Open the workbook in WPS Office Spreadsheets, show the Developer tab if you plan to use VBA, and note whether the selected range includes a header row so you can adjust the macro starting row.

Solution 1Recommended

Use a VBA Macro to Sort Each Column Independently

Best when you need a repeatable, native macro solution that does not rely on newer dynamic array functions.

A normal Excel sort rearranges entire rows. This macro loops through each column in the used range and sorts only that column in ascending order, leaving the positions of values in other columns unchanged.

1
Open the VBA editor

In WPS Office Spreadsheets, press Alt+F11, or click Developer > Visual Basic if the Developer tab is visible.

2
Insert a module

Click Insert > Module in the VBA editor to create a new code module.

3
Paste the macro

Paste the following code and adjust the start row if your data has headers: Sub SortAllColumns() Dim lastRow As Long, lastColumn As Long, i As Long lastRow = ActiveSheet.Cells(ActiveSheet.Rows.Count, 1).End(xlUp).Row lastColumn = ActiveSheet.Cells(1, ActiveSheet.Columns.Count).End(xlToLeft).Column For i = 1 To lastColumn ActiveSheet.Range(ActiveSheet.Cells(1, i), ActiveSheet.Cells(lastRow, i)).Sort Key1:=ActiveSheet.Cells(1, i), Order1:=xlAscending, Header:=xlNo Next i End Sub

4
Run the macro

Click anywhere inside the Sub SortAllColumns() code and press F5, or go to Run > Run Sub/UserForm.

Use a VBA Macro to Sort Each Column Independently
Headers in your data: If the first row contains headers, change the first data row from 1 to 2 in the lastRow and range references before running the macro.

Sort Every Column Independently with WPS Office VBA

WPS Office Spreadsheets lets you open your Excel workbook, open the built-in VBA editor, and run a small macro that sorts each column from lowest to highest without moving data across columns.

  1. 1. Open the workbook: Open your Excel workbook in WPS Office Spreadsheets.
  2. 2. Open the VBA editor: Press Alt+F11, or click Developer > Visual Basic, to open the VBA editor.
  3. 3. Create and fill a module: Click Insert > Module and paste the SortAllColumns VBA macro into the new module.
  4. 4. Run the macro: Place the cursor inside the macro and press F5, or click Run > Run Sub/UserForm, then verify each column is sorted from top to bottom.
Sort each column independently without rearranging values in other columnsFully compatible with Microsoft Excel .xlsx workbooks, so files open and save without conversionFree, lightweight spreadsheet app with a familiar ribbon and VBA macro supportLets you automate the sort with a repeatable macro instead of manual column-by-column sorting
microsoft office alternative - wps office

Frequently Asked Questions

Can I sort every column independently without using VBA?

Yes, if your spreadsheet version supports LAMBDA, REDUCE, CHOOSECOLS, and dynamic arrays, you can use a dynamic array formula to sort each column and stack the results. Otherwise the VBA macro is the most reliable method.

What should I do if my range has headers?

Adjust the macro so the sort starts at the first data row instead of row 1. For example, change Cells(1, i) to Cells(2, i) and update the lastRow detection to begin in row 2.

Why does a normal Excel sort rearrange all rows when I sort one column?

A normal sort treats each row as a record, so sorting by one column moves the entire row. Independent column sorting is not available through the standard sort dialog and requires a macro or formula.

Will the VBA macro work in WPS Office?

WPS Office on compatible Windows versions supports VBA macros. Open the VBA editor with Alt+F11 or Developer > Visual Basic, insert a module, paste the code, and run the macro.

Does the dynamic array formula work in all WPS Office versions?

No, it requires support for LAMBDA, REDUCE, CHOOSECOLS, and dynamic arrays. If you see #NAME? or #CALC!, use the VBA macro solution instead.