Fix VBA Runtime Error 1004 Caused by a Missing Stop Value in WPS Spreadsheets
Question details
A VBA loop raises Runtime Error 1004 because it searches column A for the text END OF RISKS and never finds the stopping value, so it continues beyond the worksheet’s maximum row.

- Product
- WPS Spreadsheets
- Device & OS
- not provided
- Scenario
- The user runs a VBA loop that should stop when it finds END OF RISKS in column A.
- Observed behavior
- The loop never finds the value, continues past the maximum worksheet row, and returns VBA Runtime Error 1004.
Open the affected workbook in WPS Spreadsheets and enable the Developer tab if it is not visible. Press Alt+F11 or go to Developer > Visual Basic to open the VBA editor and identify the loop that searches column A for END OF RISKS.
Add the Missing END OF RISKS Value to Column A
Use this when the loop is correct but the worksheet is simply missing the expected stopping text.
The runtime error occurs because the loop checks column A for the exact text END OF RISKS. If the cell is blank, misspelled, or contains extra spaces, the loop never stops and eventually exceeds the worksheet row limit.
Open the affected workbook in WPS Spreadsheets and go to the worksheet where the macro runs. Select the cell in column A where the loop expects to find END OF RISKS.
Type END OF RISKS in the selected cell. Make sure there are no leading or trailing spaces and the capitalization matches the VBA code.
Press Ctrl+S to save the workbook, then run the macro again from the Developer tab or by using its assigned shortcut.

Revise the VBA Loop to Stop Safely When the Stop Value Is Missing
Use this to make the macro more robust so it exits cleanly even when END OF RISKS is not present.
Fix VBA Runtime Error 1004 in WPS Spreadsheets
WPS Spreadsheets supports editing and running VBA macros, so you can correct the missing END OF RISKS stop value or add a safe loop exit condition directly in WPS Office.
- 1. Open the workbook in WPS Spreadsheets: Launch WPS Office, click Menu > Open, and select the workbook that contains the macro.
- 2. Open the VBA editor: Press Alt+F11 or click Developer > Visual Basic to open the Macro Editor.
- 3. Check the loop and stopping value: Find the loop that searches column A for END OF RISKS, then confirm whether the value exists or add a row-limit guard.
- 4. Save and run the macro: Save the workbook as a macro-enabled file if required, then run the macro to verify Runtime Error 1004 is resolved.

Frequently Asked Questions
Why does the VBA loop return Runtime Error 1004 when END OF RISKS is missing?
The loop keeps reading new rows in column A looking for the exact text. If it never finds the value, it continues until it exceeds the worksheet row limit and raises Runtime Error 1004.
Where do I check or edit the VBA code in WPS Office?
Open the workbook in WPS Spreadsheets, then press Alt+F11 or go to Developer > Visual Basic to open the VBA editor and inspect the macro.
Do I have to delete the macro if the stop value is missing?
No. You can either add END OF RISKS to the expected cell in column A or edit the loop to stop at the last row or when the cell is empty.
What should I do if the macro still fails after adding END OF RISKS?
Check the exact spelling, capitalization, and any leading or trailing spaces in the cell. Also open the VBA editor and confirm the loop comparison uses the same text. If tab_value is an array, use Erase tab_value() instead of Clear tab_value().
Can WPS Spreadsheets run Excel VBA macros?
Yes, WPS Spreadsheets supports macro-enabled workbooks and can run many Excel VBA macros, including .xlsm and .xls files, though some advanced Microsoft Office features may differ.




