PC Review


Reply
Thread Tools Rate Thread

Different outcome if I single Step or just run the code

 
 
philipp.sielfeldlyon@gmail.com
Guest
Posts: n/a
 
      21st Mar 2007
Hy, I am getting a different output running the code and stepping
through the code (F8). The code works if i single Step but it wont
work if I just run it...

Does anybody can give me an advice on how to fix this problem ??

Many thanks.

Philipp

 
Reply With Quote
 
 
 
 
NickHK
Guest
Posts: n/a
 
      21st Mar 2007
Depends what the code does, but maybe some timing issue.

NickHK

<(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hy, I am getting a different output running the code and stepping
> through the code (F8). The code works if i single Step but it wont
> work if I just run it...
>
> Does anybody can give me an advice on how to fix this problem ??
>
> Many thanks.
>
> Philipp
>



 
Reply With Quote
 
philipp.sielfeldlyon@gmail.com
Guest
Posts: n/a
 
      22nd Mar 2007
Actually it is pretty straight forward ... at least the beginning of
the code. It is only verifying a cell.

Below only part of the code... D10 is 0704 If I single step I get 0704
however if I run it it returns the error the message that it is not
0704 ...

Any idea ???

Many thanks !!!!!!

Option Explicit
Public SourceBook, TargetBook, UpdateBook, BRPBook, DCAPBook,
OldStatusbar, S As String
Public DFC As Boolean


Sub Initialise0704()
Dim i1, i2, rk1, rk2, kl, NbOfRows As Long
Dim R As Range
Dim FileToOpen As Variant
Dim RowInserted As Boolean
Dim Response As String

TargetBook = ActiveWorkbook.Name

' Open new portfoliofile

FileToOpen = Application _
.GetOpenFilename("Excel Files (*.xls), *.xls", , "Select an ER-
Portfolio-file")
If FileToOpen = "" Then
Exit Sub
Else
Workbooks.Open Filename:=FileToOpen
End If
SourceBook = ActiveWorkbook.Name
Sheets(1).Activate
If Range("D10").Value <> "0704" Then
Windows(SourceBook).Close SaveChanges:=False
MsgBox ("This procedure will open SFC0704 events only")
Exit Sub
End If

On 21 Mrz., 13:05, "NickHK" <TungChe...@Invalid.com> wrote:
> Depends what the code does, but maybe some timing issue.
>
> NickHK
>
> <philipp.sielfeldl...@gmail.com> wrote in message
>
> news:(E-Mail Removed)...
>
>
>
> > Hy, I am getting a different output running the code and stepping
> > through the code (F8). The code works if i single Step but it wont
> > work if I just run it...

>
> > Does anybody can give me an advice on how to fix this problem ??

>
> > Many thanks.

>
> > Philipp- Zitierten Text ausblenden -

>
> - Zitierten Text anzeigen -



 
Reply With Quote
 
NickHK
Guest
Posts: n/a
 
      22nd Mar 2007
It is probably because you are not referring to the sheet that you think.
This is one reason why it is better to use qualified objects e.g.

Dim WB as workbook

set WB= Workbooks.Open(Filename:=FileToOpen)
End If

If WB.Sheets(1).Range("D10").Value <> "0704" Then
WB.Close SaveChanges:=False
MsgBox "This procedure will open SFC0704 events only"
Exit Sub
'...etc

Also, you do know that:
Public SourceBook, TargetBook, UpdateBook, BRPBook, DCAPBook, OldStatusbar,
S As String

Only results in S being a string. All the others are variants. You need to
specify each data type:
Public SourceBook As String, TargetBook As String, ...etc

NickHK

<(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Actually it is pretty straight forward ... at least the beginning of
> the code. It is only verifying a cell.
>
> Below only part of the code... D10 is 0704 If I single step I get 0704
> however if I run it it returns the error the message that it is not
> 0704 ...
>
> Any idea ???
>
> Many thanks !!!!!!
>
> Option Explicit
> Public SourceBook, TargetBook, UpdateBook, BRPBook, DCAPBook,
> OldStatusbar, S As String
> Public DFC As Boolean
>
>
> Sub Initialise0704()
> Dim i1, i2, rk1, rk2, kl, NbOfRows As Long
> Dim R As Range
> Dim FileToOpen As Variant
> Dim RowInserted As Boolean
> Dim Response As String
>
> TargetBook = ActiveWorkbook.Name
>
> ' Open new portfoliofile
>
> FileToOpen = Application _
> .GetOpenFilename("Excel Files (*.xls), *.xls", , "Select an ER-
> Portfolio-file")
> If FileToOpen = "" Then
> Exit Sub
> Else
> Workbooks.Open Filename:=FileToOpen
> End If
> SourceBook = ActiveWorkbook.Name
> Sheets(1).Activate
> If Range("D10").Value <> "0704" Then
> Windows(SourceBook).Close SaveChanges:=False
> MsgBox ("This procedure will open SFC0704 events only")
> Exit Sub
> End If
>
> On 21 Mrz., 13:05, "NickHK" <TungChe...@Invalid.com> wrote:
> > Depends what the code does, but maybe some timing issue.
> >
> > NickHK
> >
> > <philipp.sielfeldl...@gmail.com> wrote in message
> >
> > news:(E-Mail Removed)...
> >
> >
> >
> > > Hy, I am getting a different output running the code and stepping
> > > through the code (F8). The code works if i single Step but it wont
> > > work if I just run it...

> >
> > > Does anybody can give me an advice on how to fix this problem ??

> >
> > > Many thanks.

> >
> > > Philipp- Zitierten Text ausblenden -

> >
> > - Zitierten Text anzeigen -

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Single Step Exception =?Utf-8?B?ZWx3b3JuaWNr?= Windows XP General 0 24th Oct 2007 04:29 PM
REQ: Practice code/files for Microsoft ADO.Net Step By Step - Please Microsoft ADO .NET 0 23rd Jun 2005 01:25 AM
Re: Works if I single step Bob Phillips Microsoft Excel Programming 0 7th Dec 2004 04:24 PM
Single Step Dialog Box Michael Thompson Microsoft Excel Programming 3 10th Dec 2003 09:58 PM
Single Step Error.... Darren Maurer Windows XP General 0 19th Jul 2003 08:27 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:02 PM.