I have some code which keeps causing an
Error 70: Permission Denied
in my VBA code. I can\'t work out why, because I know that the worksheet i
There are several answers here on StackOverflow about this VB Error. Each answer or situation is unique in reality - although each existing answer states a different potential root cause (file permissions, folder permissions, name reuse, ranges, etc).
I would recommend narrowing down the root-cause by double clicking on the side of the stating function/code in order to mark a breakpoinnt (looks like a red dot) (Alternatively, you can right click on the line of the code - Select the Toggle
and then Breakpoint
).
Next, run your code, and it will stop in your breakpoint. You can then Step-Into/Over/Out your code and essentially find the line of code that is responsible for throwing your error code. (Step Into is F8
, Step over is Shift+F8
((Go To the Debug
top menu to see more options)))
Once you identified the responsible line of code - you can start looking further.
In my case scenario, I was using a protected variable name "Date" (look into variable names). Once I renamed it to something else, the problem was fixed.