VBA & Macro Problems

Fix Excel VBA Input Error After Inserting Rows and Copying Cells

Guest WriterGuest Writer Oct 12, 2026 871 views

Question details

The user experiences a custom input error that prevents data entry in specific cells after running an Excel VBA macro designed to insert rows and copy formulas.

How to Fix Excel VBA Input Error After Inserting Rows and Copying Cells
Product
Excel
Device & OS
not provided
Scenario
Running a modified VBA macro to insert rows and copy cell formulas within a protected workbook.
Observed behavior
A custom error message blocks data entry in other cells, which is caused by the macro unexpectedly interacting with or inheriting existing data validation rules.
Before you start

Ensure you have the correct workbook password to temporarily unprotect the sheet, as you cannot check or modify data validation rules on locked cells within a protected worksheet.

Solution 1Recommended

Check and Adjust Data Validation Rules

Identify and modify the data validation settings that are triggering the custom error when the VBA script modifies the cells.

When a VBA macro inserts rows or copies cells, it can inherit or duplicate existing data validation rules from adjacent rows. If the macro or user later attempts to input data that violates these copied rules, Excel will throw a custom input error and block the action.

1
Unprotect the Worksheet

Navigate to the 'Review' tab on the ribbon and click 'Unprotect Sheet'. Enter the password if prompted, allowing you to make structural changes.

2
Select the Affected Cells

Highlight the specific cells or the newly inserted row where the input error is occurring during data entry.

3
Open Data Validation Settings

Go to the 'Data' tab and click on 'Data Validation' in the Data Tools group.

4
Review the Validation Criteria

In the 'Settings' tab, check if there is an unintended rule applied. Switch to the 'Error Alert' tab to verify if the custom error message matches the one you are seeing.

5
Clear or Modify the Rule

Click 'Clear All' to remove the validation from the affected cells, or adjust the criteria so it accommodates the macro's output, then click 'OK'.

Check and Adjust Data Validation Rules
Macro Execution Restored: Once the conflicting data validation rule is cleared, your VBA script will run correctly without triggering the input error block.
Advanced Spreadsheet Management

Manage VBA Macros and Data Validation Seamlessly in WPS Office

WPS Office provides robust support for VBA macros and complex data validation rules, allowing you to automate tasks and troubleshoot protected workbooks without compatibility issues.

  1. 1. Open your Workbook: Launch WPS Spreadsheets and open your macro-enabled workbook (.xlsm) to seamlessly load your scripts.
  2. 2. Manage Data Validation: Navigate to the 'Data' tab and click 'Validation' to easily configure, review, or clear problematic rules on your sheet.
  3. 3. Run VBA Macros: Go to the 'Developer' tab to access the built-in VBA Editor, debug your code, and run your macros smoothly.
Fully compatible with Microsoft Excel VBA macros (.xlsm) and scriptsComprehensive Data Validation tools to prevent data entry errorsLightweight and fast execution for heavy spreadsheet automationFamiliar interface makes switching from Microsoft Excel effortless
microsoft office alternative - wps office

Frequently Asked Questions

Why does inserting a row with VBA cause a validation error?

When VBA inserts a new row, Excel automatically inherits formatting and data validation rules from the row directly above it. If your macro tries to input data into the new row that violates this inherited rule, a custom input error is triggered.

How can I prevent VBA from copying data validation rules?

Instead of using a standard copy-and-paste method in your VBA script, use the PasteSpecial method. By specifying xlPasteValues or xlPasteFormulas, you ensure that only the data or formula is copied, leaving the problematic data validation rules behind.

Can a protected workbook block VBA macros?

Yes. If your VBA script attempts to modify locked cells or perform structural changes like inserting rows, it will fail. You must either have the macro temporarily unprotect the worksheet using 'ActiveSheet.Unprotect', or protect the sheet with 'UserInterfaceOnly:=True' to allow macros to run on locked sheets.