Hi Zaydah,
Thank you for posting in the Q&A Forums.
- Confirm macro settings
Ensure that Excel's macro settings are properly enabled. Follow the steps you have already tried:
Open Excel, click "File" -> "Options" -> "Trust Center" -> "Trust Center Settings "Macro Settings.
Ensure that "Enable all macros (not recommended; potentially dangerous macro code may be run)" is selected, or if for security reasons, "Enable VBA macros without notification" can be selected (this will allow macros to be run but will not be prompted each time it is opened).
- Check File Protection and Sheet Protection
File Protection: Make sure the file is not set to read-only or otherwise protected, which may prevent modifications from being saved.
Sheet Protection: Checks to see if the sheet is protected. If the worksheet is protected, certain operations (such as modifying cell contents or structure) will not be possible. You can unprotect the sheet by right-clicking on the sheet tab and selecting "Unprotect Sheet" (if you know the password). 3.
- Check for errors in the code
Error 1004 is usually related to an object reference error in VBA code. Check your VBA code to make sure that all object references are valid and that there are no attempts to access non-existent worksheets or cells.
Pay particular attention to whether fully qualified references are used when referencing workbooks and worksheets (e.g., Workbooks("WorkbookName.xlsx").Sheets("Sheet1")).
Check for any misspellings or missing object names.
- Clean up Excel and restart
Sometimes Excel may have problems due to previous errors or residual settings. Try closing all instances of Excel and then reopening it.
If the problem persists, consider restarting the computer.
- Use Excel's "Repair" feature
If you suspect that there is a problem with your Excel installation, try using Office's "Repair" feature. Right-click on the Windows Start button, select "Applications and Features", find Microsoft Office, click "Modify" or "Change", and then Select "Online Repair". 6.
- Check for other possible problems
Make sure your version of Excel is compatible with the macro code. If the code was written for an older version of Excel, you may need to make the appropriate changes in the new version.
If you are working in a network environment, check your network connection and permission settings to ensure that the macro is not blocked from executing.
Best regards
NeuviJ
============================================
If the Answer is helpful, please click "Accept Answer" and upvote it.