logo
search
VBA & Macro Problems

How to Fix Excel VBA Runtime Error 1004 After Moving a Workbook

Kushani NimanthikaKushani Nimanthika Sep 30, 2026 868 views

Question details

The user needs to fix VBA Runtime Error 1004 that occurs when running a macro after transferring an Excel workbook to another computer.

How to Fix Excel VBA Runtime Error 1004 After Moving a Workbook
Product
Microsoft Excel
Device & OS
not provided
Scenario
Running a specific macro (CalculateResults) after transferring a macro-enabled workbook from a desktop running Excel 2021 to a laptop running Excel 2016.
Observed behavior
The macro executes properly in Excel 2021 but throws a Runtime Error 1004 (application-defined or object-defined error) in Excel 2016.
Before you start

Before modifying your VBA scripts, save a backup copy of your macro-enabled workbook (.xlsm) to prevent any accidental loss of functional code.

Solution 1Recommended

Replace Select and ActiveCell with Direct Object References

Avoid using Select, Selection, and ActiveCell commands, which frequently cause Error 1004 across different Excel versions, by referencing objects directly.

When a workbook is moved between Excel versions (like 2021 to 2016), implicitly referencing active sheets or cells can trigger application-defined errors if the focus shifts unexpectedly. Explicitly defining your workbooks, worksheets, and ranges ensures the macro always targets the exact location regardless of what is currently selected on screen.

1
Open the VBA Editor

Press Alt + F11 on your keyboard to open the Visual Basic for Applications (VBA) editor.

2
Locate the problematic macro

In the Project Explorer pane on the left, double-click the module containing your CalculateResults macro to view the code.

3
Identify indirect references

Scan your code for lines that use '.Select', 'Selection', or 'ActiveCell'. For example, look for patterns like 'Worksheets("Sheet1").Select' followed by 'Range("A1").Select'.

4
Rewrite with direct references

Combine the lines to reference the object directly. Change 'Range("A1").Select' and 'Selection.Copy' into a single statement like 'Worksheets("Sheet1").Range("A1").Copy'.

5
Test the macro

Save your changes, close the VBA editor, and run the macro in Excel 2016 to verify that Runtime Error 1004 is resolved.

Replace Select and ActiveCell with Direct Object References
Best Practice: Using direct referencing is a highly recommended VBA best practice. It significantly improves code execution speed and ensures better compatibility between Microsoft Office versions.
Free Microsoft Office alternative

Try WPS Office for Seamless Spreadsheet Management

If you frequently encounter version compatibility issues or runtime errors when transferring files between different Microsoft Office versions, consider switching to WPS Office. It provides a highly compatible spreadsheet environment that handles complex data effortlessly.

  1. 1. Download WPS Office: Visit the official WPS Office website to download and install the free software on your computer.
  2. 2. Open WPS Spreadsheet: Launch the WPS Office suite and click on the 'Spreadsheet' module.
  3. 3. Load your file: Click 'Menu' > 'Open' to import your existing Excel files and start managing your data seamlessly.
Free to download and use for essential everyday office tasks.Highly compatible with Microsoft Excel formats, including .xlsx, .xls, and .csv.Lightweight installation with incredibly fast startup speeds.Familiar, user-friendly interface requiring no learning curve.
microsoft office alternative - wps office

Frequently Asked Questions

What does VBA Runtime Error 1004 mean?

Runtime Error 1004 is a generic error in Excel VBA that typically means 'Application-defined or object-defined error.' It usually occurs when your code attempts to reference an object, like a worksheet or cell range, that doesn't exist, is misspelled, or isn't currently active when using implicit references.

Why does my macro work in Excel 2021 but fail in Excel 2016?

Newer versions of Excel introduce new functions, dynamic arrays, and background behaviors that might not be supported in Excel 2016. Furthermore, differences in how the VBA engine handles active windows or unreferenced objects can cause macros to fail on older desktop environments.

How do I share a sanitized workbook for troubleshooting?

A sanitized workbook is a copy of your file with all sensitive or confidential information removed or replaced with dummy data. Save this copy, upload it to a reliable cloud service like Dropbox or Google Drive, and generate a shareable link to provide to support forums for secure troubleshooting.