change value while debugging

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Is there any way to change a value of a variable whilst in the debugger.
The initialisation of a variable was in the wrong place so the macro
stopped. I know what it should have been, and I have now corrected the code,
but I also have to repair the spreadsheet, it would have been so much easier
if I could have changed the value and then continued to run the rest of the
code.

Is this possible? (XL2003) and how do I do it?
 
Graham,

When you stop, go to the line below the highlighted line, and enter a new line of code

myStrVariable = "NewValue"
or
myIntVariable = 3

as appropriate, then step through using F8, and comment out your new line after you have executed
it.

HTH,
Bernie
MS Excel MVP
 
Bernie
Clever, but, I couldn't get past the line as it was a cell coordinate of 0,
it's a shame the current cell isn't Cells(0,0) !
Thanks I shall remember the tip for future reference.
 
Graham,

Temporarily overwrite the variable in the highlighted code with a constant - the debugger may or may
not allow you to get away with it....

HTH,
Bernie
MS Excel MVP
 
I'm pretty sure the answer is "no", you can't change the value of a
variable in the debugger. I have gotten into the habit of saving my
files before running untested code- if there is a catastrophic failure
I can close the file without saving to revert to the earlier version.
 
Back
Top