ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Not able to "Step in" - Debug (https://www.excelbanter.com/excel-programming/301448-not-able-step-debug.html)

Hari[_3_]

Not able to "Step in" - Debug
 

Hi,

I have a Sub Workbook_BeforeSave. (This sub further calls another Function)

The file doesnt save if there are any inconsistency within the file's data
and flags the errors with a yellow fill color.

I have inputted correct data but the file is not saving and giving a message
that one particular cell has incorrect data and has filled it with yellow
color.

Now, I want to run this sub by stepping in to it ( step by step with F8 )so
that I get a better understanding of why it is happening.

But in VB when I choose Workbook_beforesave and press F8, nothing happens.

Where am I going wrong ?

Regards,
Hari
India



JE McGimpsey

Not able to "Step in" - Debug
 
You can't start a sub with an argument using F8.

However, if you set a breakpoint at the first statement in the macro and
choose Save from the workbook, you'll be dumped into the VBE and you can
step with F8.

In article ,
"Hari" wrote:

I have a Sub Workbook_BeforeSave. (This sub further calls another Function)

The file doesnt save if there are any inconsistency within the file's data
and flags the errors with a yellow fill color.

I have inputted correct data but the file is not saving and giving a message
that one particular cell has incorrect data and has filled it with yellow
color.

Now, I want to run this sub by stepping in to it ( step by step with F8 )so
that I get a better understanding of why it is happening.

But in VB when I choose Workbook_beforesave and press F8, nothing happens.

Where am I going wrong ?


TroyW[_2_]

Not able to "Step in" - Debug
 
Hari,

Another method is to insert the command "Stop" in the code. When the
program encounters the Stop command it will halt execution and place you
into debug mode waiting for you to use F8 to continue executing the program
line-by-line. Of course, you would want to remove "Stop" from your code
after you're done debugging.

You can also do fancy things like using a variable to turn on and off the
debug code. You can declare a Public Boolean variable that turns on and off
all of your lines of debug code. In the example below, I've created a
boolean named: PbDebugOn

At the beginning of the code you would set the variable True.
PbDebugOn = True

Then lines like the one below would evaluate True and stop your code in
debug mode.
If PbDebugOn = True and iCount 100 then Stop

Troy


Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
Stop '''Code will stop and wait.
'''The rest of your code below.

End Sub

"Hari" wrote in message
...

Hi,

I have a Sub Workbook_BeforeSave. (This sub further calls another

Function)

The file doesnt save if there are any inconsistency within the file's data
and flags the errors with a yellow fill color.

I have inputted correct data but the file is not saving and giving a

message
that one particular cell has incorrect data and has filled it with yellow
color.

Now, I want to run this sub by stepping in to it ( step by step with

F8 )so
that I get a better understanding of why it is happening.

But in VB when I choose Workbook_beforesave and press F8, nothing happens.

Where am I going wrong ?

Regards,
Hari
India





Hari[_3_]

Not able to "Step in" - Debug
 
Hi Troy and JE M

Thanx a lot for ur help. Im able to pin down the error.

Regards,
Hari
India


"TroyW" wrote in message
...
Hari,

Another method is to insert the command "Stop" in the code. When the
program encounters the Stop command it will halt execution and place you
into debug mode waiting for you to use F8 to continue executing the

program
line-by-line. Of course, you would want to remove "Stop" from your code
after you're done debugging.

You can also do fancy things like using a variable to turn on and off the
debug code. You can declare a Public Boolean variable that turns on and

off
all of your lines of debug code. In the example below, I've created a
boolean named: PbDebugOn

At the beginning of the code you would set the variable True.
PbDebugOn = True

Then lines like the one below would evaluate True and stop your code in
debug mode.
If PbDebugOn = True and iCount 100 then Stop

Troy


Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
Stop '''Code will stop and wait.
'''The rest of your code below.

End Sub

"Hari" wrote in message
...

Hi,

I have a Sub Workbook_BeforeSave. (This sub further calls another

Function)

The file doesnt save if there are any inconsistency within the file's

data
and flags the errors with a yellow fill color.

I have inputted correct data but the file is not saving and giving a

message
that one particular cell has incorrect data and has filled it with

yellow
color.

Now, I want to run this sub by stepping in to it ( step by step with

F8 )so
that I get a better understanding of why it is happening.

But in VB when I choose Workbook_beforesave and press F8, nothing

happens.

Where am I going wrong ?

Regards,
Hari
India








All times are GMT +1. The time now is 09:04 PM.

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