VBA & Macro Problems

How to Convert a Contiguous Excel Range into Individual Cell Selections in WPS Office

Khadija KhanKhadija Khan Nov 13, 2026 868 views

Question details

The user needs to convert a selected contiguous Excel range into separate cell selections so a row can be inserted for each TRUE value without inserting all selected rows together.

How to Convert a Contiguous Excel Range into Individual Cell Selections in WPS Office
Product
WPS Spreadsheets
Device & OS
not provided
Scenario
The user has a contiguous range selected and wants to treat each cell independently before inserting rows only for cells that evaluate to TRUE.
Observed behavior
A normal contiguous selection causes WPS Spreadsheets to insert rows for the whole selected area at once instead of creating individual selections for each qualifying cell.
Before you start

Make sure the workbook is macro-enabled and the Developer tab is available in WPS Spreadsheets, then open the workbook that contains the range you want to convert.

Solution 1Recommended

Convert a Selected Range to Individual Cell Selections with a VBA Macro

Use this method when you need each cell in a selected contiguous range to be treated as an independent selection before inserting rows for TRUE values.

The macro reads each cell in the current selection, builds a comma-separated list of individual cell addresses, and then re-selects that list. This creates separate selection areas instead of one rectangular range.

1
Open the VBA editor

In WPS Spreadsheets, go to the Developer tab and click Visual Basic, or press Alt+F11. If the Developer tab is not visible, enable it from File > Options > Customize Ribbon.

2
Insert a standard module

In the VBA editor, click Insert > Module to create a new standard module where the macro will be stored.

3
Paste the VBA macro code

Paste the following code into the module: Sub ConvertSelection() Dim s As String Dim cel As Range For Each cel In Selection s = s & "," & cel.Address(False, False) Next cel s = Mid(s, 2) Range(s).Select End Sub

4
Run the macro on the selected range

Return to the worksheet, select the contiguous range, then press Alt+F8, choose ConvertSelection, and click Run. The range is rebuilt as separate individual cell selections.

Convert a Selected Range to Individual Cell Selections with a VBA Macro
Keep the macro available: Store this code in PERSONAL.XLSB if you want to use it in all open workbooks, and assign it to a keyboard shortcut or Quick Access Toolbar button in WPS Spreadsheets.
WPS Spreadsheets VBA Macro

Use a VBA Macro in WPS Spreadsheets to Select Individual Cells from a Contiguous Range

WPS Office can run VBA macros directly, so you can convert a contiguous Excel range into separate cell selections and then insert rows only for the TRUE values you need. The same familiar VBA workflow works in WPS Spreadsheets without switching to another Office suite.

  1. 1. Download and install WPS Office: Go to the official WPS Office website, download the free installer, and complete the installation.
  2. 2. Open your Excel workbook in WPS Spreadsheets: Launch WPS Office, click Spreadsheets, and open the .xlsx or .xlsm workbook that contains the range.
  3. 3. Enable the Developer tab: Click File > Options > Customize Ribbon, tick Developer, and click OK.
  4. 4. Create the ConvertSelection macro: Press Alt+F11 to open the VBA editor, click Insert > Module, paste the VBA code, and save the workbook in a macro-enabled format.
  5. 5. Run the macro: Select the contiguous range, press Alt+F8, choose ConvertSelection, and click Run to convert it into individual cell selections.
Runs the ConvertSelection VBA macro directly in WPS SpreadsheetsCreates individual cell selections so you can insert rows for TRUE values without affecting the whole rangeOpens and saves Excel-compatible .xls, .xlsx, and .xlsm filesFree, lightweight Office suite with a familiar ribbon and VBA editorSupports Personal Macro Workbook and macro shortcuts
microsoft office alternative - wps office

Frequently Asked Questions

Does the ConvertSelection macro work in WPS Spreadsheets?

Yes. WPS Spreadsheets supports VBA macro execution. Open the workbook in WPS Spreadsheets, press Alt+F11 to open the VBA editor, and run the macro from Alt+F8.

Why is my macro not saved in a .xlsx file?

The .xlsx format does not retain VBA macros. Save the workbook as a macro-enabled workbook such as .xlsm, or store the macro in PERSONAL.XLSB if you want it available in all workbooks.

Can I insert rows only for cells that contain TRUE after running this macro?

The macro only changes the selection shape into individual cell selections. After you run it, use the worksheet Insert Sheet Rows command or another macro to insert rows for each selected cell.

What should I check if I get a 'Range method failed' error?

Make sure a valid cell range is selected before running the macro, and paste the code into a standard module rather than a worksheet module.

How do I make this macro available in every workbook?

Open the VBA editor, locate PERSONAL.XLSB, insert a module there, and paste the macro. You can then assign it to a Quick Access Toolbar button or keyboard shortcut.