Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 157
Default 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


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default 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 ?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 94
Default 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




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 157
Default 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






Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell Steve Kay Excel Discussion (Misc queries) 2 August 8th 08 01:54 AM
change "true" and "false" to "availble" and "out of stock" inthestands Excel Worksheet Functions 2 July 19th 07 07:05 PM
Count occurences of "1"/"0" (or"TRUE"/"FALSE") in a row w. conditions in the next BCB New Users to Excel 7 May 13th 06 10:02 PM
Only step through cells that are "Active" WintonCw Excel Programming 4 May 14th 04 11:32 PM
"Multiple-step operation generated errors" Michael Daly Excel Programming 2 December 22nd 03 09:30 AM


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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"