Add Option Explicit to the top of your VBA code. Remove unused variables and declare the rest. https://excelmacromastery.com/vba-error-handling / "On Error Resume Next , is the most commonly used and misused form. It instructs to VBA to essentially ignore the error and resume execution on the next line of code. It is very important to remember that On Error Resume Next does not in any way "fix" the error." http://www.cpearson.com/excel/errorhandling.htm