VBA & Macro Problems

How to Fix SpecialCells Not Deleting Rows with Formula Results in WPS Spreadsheets

Phi Hung VoPhi Hung Vo Nov 13, 2026 868 views

Question details

The user runs a VBA macro that tries to delete rows using SpecialCells(xlCellTypeConstants, 4), but the helper column contains formulas that return the target value, so SpecialCells finds no cells and no rows are deleted.

How to Fix SpecialCells Not Deleting Rows with Formula Results in WPS Spreadsheets
Product
WPS Spreadsheets
Device & OS
not provided
Scenario
Automate row deletion when a helper column formula evaluates to a specific value.
Observed behavior
SpecialCells returns no cells because it only considers constant values, not formula results; the matching rows remain in the worksheet.
Before you start

Save the workbook as a macro-enabled file and confirm that the helper column, for example column J, contains the formulas you intend to convert before running the macro.

Solution 1Recommended

Convert the Helper Column Formulas to Values Before Using SpecialCells

Use this when you want to keep the existing SpecialCells deletion code and make the helper column results visible as constants.

xlCellTypeConstants identifies only cells that contain literal values. If column J contains formulas returning 2, the cells are not considered constants, even when the displayed result is 2. Converting them to values makes the results visible to SpecialCells.

1
Select and copy the helper column

In WPS Spreadsheets, open the workbook and select column J, then press Ctrl+C to copy the helper column.

2
Paste the values back to column J

Right-click column J and choose Paste Special > Values, or run Columns("J:J").PasteSpecial Paste:=xlPasteValuesAndNumberFormats in the VBA editor.

3
Run the SpecialCells deletion macro

Run your existing code that calls SpecialCells(xlCellTypeConstants, 4).EntireRow.Delete; the matching rows will now be detected and deleted.

Convert the Helper Column Formulas to Values Before Using SpecialCells
Result: After pasting as values, SpecialCells can detect the helper column cells and the macro deletes the matching rows.
WPS Spreadsheets VBA fix

Delete Rows with Formula Results in WPS Spreadsheets VBA

Use WPS Spreadsheets to paste helper formulas as values and run your SpecialCells macro, or loop through formula results directly. WPS Office provides familiar VBA support so Excel macro workflows can be completed in a free, lightweight app.

  1. 1. Open the macro-enabled workbook in WPS Spreadsheets: Launch WPS Office and open the .xlsm workbook that contains the VBA deletion macro.
  2. 2. Convert the helper column to values: Select the helper column, such as column J, and click Home > Paste > Values to replace formulas with their results.
  3. 3. Open the VBA editor: Press Alt+F11 and locate the existing SpecialCells(xlCellTypeConstants, 4).EntireRow.Delete macro.
  4. 4. Run the macro: Press F5 to run the macro; WPS Spreadsheets deletes the rows where the helper column now contains the matching constant value.
VBA macro support for Excel-compatible .xls, .xlsx, and .xlsm workbooksFree, lightweight Office suite with a familiar ribbon and VBA editorPaste Special values workflow resolves the SpecialCells constant-only limitationDirect compatibility with Microsoft Excel macro-enabled filesNo need to rewrite existing Excel VBA deletion logic
microsoft office alternative - wps office

Frequently Asked Questions

Does SpecialCells work with formula results?

No. xlCellTypeConstants only returns cells containing literal values, so a formula that returns the same value is not included. Convert formulas to values or use a loop to evaluate formula results.

How do I convert formula results to values in WPS Spreadsheets?

Select the helper column, press Ctrl+C, then right-click and choose Paste Special > Values. In VBA, use Columns("J:J").PasteSpecial Paste:=xlPasteValuesAndNumberFormats.

Can I delete rows based on formula results without changing formulas?

Yes. Loop through the cells from the last row upward and delete rows where the cell value matches, for example If Range("J" & i).Value = 2 Then Rows(i).Delete.

Why does my SpecialCells code return no cells?

Because the column likely contains formulas, not constants. SpecialCells(xlCellTypeConstants, 4) only detects constant values, so it skips formula results even if the displayed value is the target.

Does WPS Spreadsheets support Excel VBA macros?

Yes. WPS Office supports VBA macros and can open macro-enabled Excel files, but some advanced Excel-specific objects may behave differently, so test your macro in WPS Spreadsheets.