ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   change value while debugging (https://www.excelbanter.com/excel-discussion-misc-queries/140146-change-value-while-debugging.html)

Graham Y

change value while debugging
 
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?

Bernie Deitrick

change value while debugging
 
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


"Graham Y" wrote in message
...
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 Y

change value while debugging
 
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.

"Bernie Deitrick" wrote:

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


"Graham Y" wrote in message
...
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?





Bernie Deitrick

change value while debugging
 
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


"Graham Y" wrote in message
...
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.

"Bernie Deitrick" wrote:

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


"Graham Y" wrote in message
...
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?







DaveO[_2_]

change value while debugging
 
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.



All times are GMT +1. The time now is 08:26 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com