ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How do I step a Macro through a spreadsheet (https://www.excelbanter.com/excel-programming/369079-how-do-i-step-macro-through-spreadsheet.html)

Sarahds[_2_]

How do I step a Macro through a spreadsheet
 

I am trying to find out what a particular macro does as it's not
behaving the way I would expect it to. How do I run it in "step Mode"
so I can see what each step is doing?

Sarah


--
Sarahds


------------------------------------------------------------------------
Sarahds's Profile: http://www.excelforum.com/member.php...o&userid=37005
View this thread: http://www.excelforum.com/showthread...hreadid=567313


NickHK

How do I step a Macro through a spreadsheet
 
First, it's easier to arrange the VBA IDE window and the Excel window so you
can see both at the both together.
Put a breakpoint on the line of code from which you want to start stepping
through: Left click in the left hand border of the window that contains the
code you want to examine. You will get a red dot in the border and that
whole line will have be red. It must be an executable line of code i.e NOT a
comment or Dim .
Trigger you code however it is supposed to start.
When you are in Break Mode (by your break point being reached, you can step
through the code line-by-line by pressing the F8 keys.
You can enter any valid code the Immediate (debug) window, to either set a
value or query a value, then press Enter:
To check:
?activecell.address [Enter]
To set
activecell.value="New Value" [Enter]

You can remove breakpoints by clicking on the red dot again.

Check out Debug in the VBA Help.

NickHK

"Sarahds" wrote in
message ...

I am trying to find out what a particular macro does as it's not
behaving the way I would expect it to. How do I run it in "step Mode"
so I can see what each step is doing?

Sarah


--
Sarahds


------------------------------------------------------------------------
Sarahds's Profile:

http://www.excelforum.com/member.php...o&userid=37005
View this thread: http://www.excelforum.com/showthread...hreadid=567313





All times are GMT +1. The time now is 03:37 AM.

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