VBA & Macro Problems

WPS Spreadsheets VBA Macro to Clear Cells on Every Worksheet Except One

Algirdas JasaitisAlgirdas Jasaitis Nov 12, 2026 869 views

Question details

You need a VBA macro that clears cells E18:F19 on every worksheet except the worksheet named Action.

Product
WPS Spreadsheets VBA
Device & OS
not provided
Scenario
A workbook contains multiple worksheets, and the same cell range must be cleared across all of them except one specified worksheet.
Observed behavior
The goal is to clear the contents of E18:F19 on every worksheet whose name is not Action, regardless of the number of worksheets in the workbook.
Before you start

Confirm that the worksheet to preserve is named exactly Action, including capitalization and spaces. Save the workbook in a macro-enabled format such as .xlsm if your WPS Office version requires it for VBA projects.

Solution 1Recommended

Run a VBA macro that clears E18:F19 except on the Action sheet

Use this solution when the same range must be cleared across all worksheets while leaving the Action worksheet unchanged.

The macro loops through every worksheet in the workbook and uses the worksheet name as the exclusion rule. Screen updating is temporarily disabled so the operation runs without visibly refreshing each sheet.

1
Open the VBA editor

In WPS Spreadsheets, open the workbook and press Alt+F11 to open the VBA editor.

2
Insert a standard module

In the VBA editor, select Insert > Module, then paste this code into the new standard module: Sub ClearData() Dim wsh As Worksheet Application.ScreenUpdating = False For Each wsh In Worksheets If wsh.Name <> "Action" Then wsh.Range("E18:F19").ClearContents End If Next wsh Application.ScreenUpdating = True End Sub

3
Run the macro

Place the cursor inside the ClearData procedure and select Run > Run Sub/UserForm, or press F5. The contents of E18:F19 are cleared from every worksheet except Action.

Expected result: The Action worksheet remains unchanged, while E18:F19 is cleared on every other worksheet in the workbook.

Automate worksheet cleanup with VBA in WPS Spreadsheets

WPS Spreadsheets lets you use a VBA macro to process every worksheet, apply an exclusion rule for the Action sheet, and clear the specified cell range in one run instead of editing tabs manually.

  1. 1. Open the workbook: Launch WPS Spreadsheets and open the workbook containing the worksheets to process.
  2. 2. Open the VBA editor: Press Alt+F11, then choose Insert > Module in the VBA editor.
  3. 3. Add the cleanup macro: Paste the ClearData procedure into the standard module and confirm that the excluded sheet name and target range are correct.
  4. 4. Execute the procedure: Click inside the macro and choose Run > Run Sub/UserForm, or press F5, to clear E18:F19 on the applicable worksheets.
Clear the same range across many worksheets automatically.Exclude a worksheet by its exact tab name.Use a familiar spreadsheet interface with VBA macro tools.Open and work with Microsoft Excel .xlsx and .xlsm files.Reduce repetitive worksheet cleanup and save time.
microsoft office alternative - wps office

Frequently Asked Questions

Will the macro clear data on the Action worksheet?

No. The condition If wsh.Name <> "Action" excludes the worksheet whose tab name is exactly Action. All other worksheets are processed.

Does ClearContents remove formatting from E18:F19?

No. ClearContents removes cell values and formulas but keeps formatting, borders, and other cell settings.

What happens if the workbook has more worksheets?

The For Each wsh In Worksheets loop automatically processes every worksheet in the workbook, so no worksheet count needs to be entered manually.

What if the sheet is named Action with extra spaces?

The name must match exactly. Rename the tab to Action or update the condition in the macro to use the worksheet's actual name.

Can I change the cells that the macro clears?

Yes. Replace wsh.Range("E18:F19") with another range, such as wsh.Range("A1:B10"), before running the procedure.