PC Review


Reply
Thread Tools Rate Thread

different results when debugging

 
 
juls001
Guest
Posts: n/a
 
      22nd Feb 2007
HI

I'm trying to copy some data from excel into a table in word, I loop
through the excel spreadsheet and put the data into the word table:

Do

oTable.Cell(i, 1).Range = Right(ActiveCell.Offset(0,
0).Value, 7)
oTable.Cell(i, 2).Range = ActiveCell.Offset(0, 1).Value
oTable.Cell(i, 3).Range = ActiveCell.Offset(0, 2).Value
oTable.Cell(i, 4).Range =
FormatNumber(ActiveCell.Offset(0, 3).Value, 2)

i = i + 1
ActiveCell.Offset(1, 0).Select
If IsEmpty(ActiveCell) = False Then
wrdDoc.Tables(4).Rows.Add
End If

It works fine (ie all 12 rows are copied) when I'm debugging, however
when I run it from the userform it gives me different results eg
sometimes 2 or 12 rows are there, sometimes 10 or 12 rows etc.

Can anyone help? Thanks in advance

 
Reply With Quote
 
 
 
 
Jim Cone
Guest
Posts: n/a
 
      22nd Feb 2007

Is the same sheet active in both scenarios?
Is the active cell the same?
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware


"juls001" <(E-Mail Removed)>
wrote in message
HI
I'm trying to copy some data from excel into a table in word, I loop
through the excel spreadsheet and put the data into the word table:
Do
oTable.Cell(i, 1).Range = Right(ActiveCell.Offset(0, 0).Value, 7)
oTable.Cell(i, 2).Range = ActiveCell.Offset(0, 1).Value
oTable.Cell(i, 3).Range = ActiveCell.Offset(0, 2).Value
oTable.Cell(i, 4).Range =
FormatNumber(ActiveCell.Offset(0, 3).Value, 2)

i = i + 1
ActiveCell.Offset(1, 0).Select
If IsEmpty(ActiveCell) = False Then
wrdDoc.Tables(4).Rows.Add
End If

It works fine (ie all 12 rows are copied) when I'm debugging, however
when I run it from the userform it gives me different results eg
sometimes 2 or 12 rows are there, sometimes 10 or 12 rows etc.
Can anyone help? Thanks in advance

 
Reply With Quote
 
juls001
Guest
Posts: n/a
 
      22nd Feb 2007
On Feb 22, 1:13 pm, "Jim Cone" <jim.cone...@rcn.comXXX> wrote:
> Is the same sheet active in both scenarios?
> Is the active cell the same?
> --
> Jim Cone
> San Francisco, USAhttp://www.realezsites.com/bus/primitivesoftware
>
> "juls001" <lukedoddr...@gmail.com>
> wrote in message
> HI
> I'm trying to copy some data from excel into a table in word, I loop
> through the excel spreadsheet and put the data into the word table:
> Do
> oTable.Cell(i, 1).Range = Right(ActiveCell.Offset(0, 0).Value, 7)
> oTable.Cell(i, 2).Range = ActiveCell.Offset(0, 1).Value
> oTable.Cell(i, 3).Range = ActiveCell.Offset(0, 2).Value
> oTable.Cell(i, 4).Range =
> FormatNumber(ActiveCell.Offset(0, 3).Value, 2)
>
> i = i + 1
> ActiveCell.Offset(1, 0).Select
> If IsEmpty(ActiveCell) = False Then
> wrdDoc.Tables(4).Rows.Add
> End If
>
> It works fine (ie all 12 rows are copied) when I'm debugging, however
> when I run it from the userform it gives me different results eg
> sometimes 2 or 12 rows are there, sometimes 10 or 12 rows etc.
> Can anyone help? Thanks in advance


Hi Jim
Yes to both, any ideas? I thought that it might have something to do
with optimization?
Thanks
Juliette

 
Reply With Quote
 
Jean-Yves
Guest
Posts: n/a
 
      22nd Feb 2007
Hi,

Try adding debuging code so you can trace in the immediate window the steps
done

>> Do
>> oTable.Cell(i, 1).Range = Right(ActiveCell.Offset(0, 0).Value,
>> 7)

debug.print "Value I " & I & "Row 1" =
Right(ActiveCell.Offset(0, 0).Value, 7)
>> oTable.Cell(i, 2).Range = ActiveCell.Offset(0, 1).Value
>> oTable.Cell(i, 3).Range = ActiveCell.Offset(0, 2).Value
>> oTable.Cell(i, 4).Range = FormatNumber(ActiveCell.Offset(0,
>> 3).Value, 2)
>>
>> i = i + 1

debug.print "Value I :" & i

Regards
JY


"juls001" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> On Feb 22, 1:13 pm, "Jim Cone" <jim.cone...@rcn.comXXX> wrote:
>> Is the same sheet active in both scenarios?
>> Is the active cell the same?
>> --
>> Jim Cone
>> San Francisco, USAhttp://www.realezsites.com/bus/primitivesoftware
>>
>> "juls001" <lukedoddr...@gmail.com>
>> wrote in message
>> HI
>> I'm trying to copy some data from excel into a table in word, I loop
>> through the excel spreadsheet and put the data into the word table:
>> Do
>> oTable.Cell(i, 1).Range = Right(ActiveCell.Offset(0, 0).Value,
>> 7)
>> oTable.Cell(i, 2).Range = ActiveCell.Offset(0, 1).Value
>> oTable.Cell(i, 3).Range = ActiveCell.Offset(0, 2).Value
>> oTable.Cell(i, 4).Range =
>> FormatNumber(ActiveCell.Offset(0, 3).Value, 2)
>>
>> i = i + 1
>> ActiveCell.Offset(1, 0).Select
>> If IsEmpty(ActiveCell) = False Then
>> wrdDoc.Tables(4).Rows.Add
>> End If
>>
>> It works fine (ie all 12 rows are copied) when I'm debugging, however
>> when I run it from the userform it gives me different results eg
>> sometimes 2 or 12 rows are there, sometimes 10 or 12 rows etc.
>> Can anyone help? Thanks in advance

>
> Hi Jim
> Yes to both, any ideas? I thought that it might have something to do
> with optimization?
> Thanks
> Juliette
>



 
Reply With Quote
 
juls001
Guest
Posts: n/a
 
      22nd Feb 2007
On Feb 22, 2:55 pm, "Jean-Yves" <nomail_I_hate_s...@spam.com> wrote:
> Hi,
>
> Try adding debuging code so you can trace in the immediate window the steps
> done
>
> >> Do
> >> oTable.Cell(i, 1).Range = Right(ActiveCell.Offset(0, 0).Value,
> >> 7)

>
> debug.print "Value I " & I & "Row 1" =
> Right(ActiveCell.Offset(0, 0).Value, 7)>> oTable.Cell(i, 2).Range = ActiveCell.Offset(0, 1).Value
> >> oTable.Cell(i, 3).Range = ActiveCell.Offset(0, 2).Value
> >> oTable.Cell(i, 4).Range = FormatNumber(ActiveCell.Offset(0,
> >> 3).Value, 2)

>
> >> i = i + 1

>
> debug.print "Value I :" & i
>
> Regards
> JY
>
> "juls001" <lukedoddr...@gmail.com> wrote in message
>
> news:(E-Mail Removed)...
>
>
>
> > On Feb 22, 1:13 pm, "Jim Cone" <jim.cone...@rcn.comXXX> wrote:
> >> Is the same sheet active in both scenarios?
> >> Is the active cell the same?
> >> --
> >> Jim Cone
> >> San Francisco, USAhttp://www.realezsites.com/bus/primitivesoftware

>
> >> "juls001" <lukedoddr...@gmail.com>
> >> wrote in message
> >> HI
> >> I'm trying to copy some data from excel into a table in word, I loop
> >> through the excel spreadsheet and put the data into the word table:
> >> Do
> >> oTable.Cell(i, 1).Range = Right(ActiveCell.Offset(0, 0).Value,
> >> 7)
> >> oTable.Cell(i, 2).Range = ActiveCell.Offset(0, 1).Value
> >> oTable.Cell(i, 3).Range = ActiveCell.Offset(0, 2).Value
> >> oTable.Cell(i, 4).Range =
> >> FormatNumber(ActiveCell.Offset(0, 3).Value, 2)

>
> >> i = i + 1
> >> ActiveCell.Offset(1, 0).Select
> >> If IsEmpty(ActiveCell) = False Then
> >> wrdDoc.Tables(4).Rows.Add
> >> End If

>
> >> It works fine (ie all 12 rows are copied) when I'm debugging, however
> >> when I run it from the userform it gives me different results eg
> >> sometimes 2 or 12 rows are there, sometimes 10 or 12 rows etc.
> >> Can anyone help? Thanks in advance

>
> > Hi Jim
> > Yes to both, any ideas? I thought that it might have something to do
> > with optimization?
> > Thanks
> > Juliette- Hide quoted text -

>
> - Show quoted text -


Hi
I get what I would expect it to be writing in the table except its
not.
Thanks
Juliette

 
Reply With Quote
 
juls001
Guest
Posts: n/a
 
      22nd Feb 2007
On Feb 22, 3:15 pm, "juls001" <lukedoddr...@gmail.com> wrote:
> On Feb 22, 2:55 pm, "Jean-Yves" <nomail_I_hate_s...@spam.com> wrote:
>
>
>
>
>
> > Hi,

>
> > Try adding debuging code so you can trace in the immediate window the steps
> > done

>
> > >> Do
> > >> oTable.Cell(i, 1).Range = Right(ActiveCell.Offset(0, 0).Value,
> > >> 7)

>
> > debug.print "Value I " & I & "Row 1" =
> > Right(ActiveCell.Offset(0, 0).Value, 7)>> oTable.Cell(i, 2).Range = ActiveCell.Offset(0, 1).Value
> > >> oTable.Cell(i, 3).Range = ActiveCell.Offset(0, 2).Value
> > >> oTable.Cell(i, 4).Range = FormatNumber(ActiveCell.Offset(0,
> > >> 3).Value, 2)

>
> > >> i = i + 1

>
> > debug.print "Value I :" & i

>
> > Regards
> > JY

>
> > "juls001" <lukedoddr...@gmail.com> wrote in message

>
> >news:(E-Mail Removed)...

>
> > > On Feb 22, 1:13 pm, "Jim Cone" <jim.cone...@rcn.comXXX> wrote:
> > >> Is the same sheet active in both scenarios?
> > >> Is the active cell the same?
> > >> --
> > >> Jim Cone
> > >> San Francisco, USAhttp://www.realezsites.com/bus/primitivesoftware

>
> > >> "juls001" <lukedoddr...@gmail.com>
> > >> wrote in message
> > >> HI
> > >> I'm trying to copy some data from excel into a table in word, I loop
> > >> through the excel spreadsheet and put the data into the word table:
> > >> Do
> > >> oTable.Cell(i, 1).Range = Right(ActiveCell.Offset(0, 0).Value,
> > >> 7)
> > >> oTable.Cell(i, 2).Range = ActiveCell.Offset(0, 1).Value
> > >> oTable.Cell(i, 3).Range = ActiveCell.Offset(0, 2).Value
> > >> oTable.Cell(i, 4).Range =
> > >> FormatNumber(ActiveCell.Offset(0, 3).Value, 2)

>
> > >> i = i + 1
> > >> ActiveCell.Offset(1, 0).Select
> > >> If IsEmpty(ActiveCell) = False Then
> > >> wrdDoc.Tables(4).Rows.Add
> > >> End If

>
> > >> It works fine (ie all 12 rows are copied) when I'm debugging, however
> > >> when I run it from the userform it gives me different results eg
> > >> sometimes 2 or 12 rows are there, sometimes 10 or 12 rows etc.
> > >> Can anyone help? Thanks in advance

>
> > > Hi Jim
> > > Yes to both, any ideas? I thought that it might have something to do
> > > with optimization?
> > > Thanks
> > > Juliette- Hide quoted text -

>
> > - Show quoted text -

>
> Hi
> I get what I would expect it to be writing in the table except its
> not.
> Thanks
> Juliette- Hide quoted text -
>
> - Show quoted text -


HI
further info, if I add two message boxs at the beginning of the loop
(one shows me value of 1 and the other value of activecell) and I
therefore have keep on clicking ok it all works fine as long as I
don't click ok too quickly.....

 
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
How can I skip debugging Ajax when debugging my code? AAaron123 Microsoft ASP .NET 3 28th Jul 2009 05:07 PM
View Debugging Results Jerry Microsoft ASP .NET 2 26th May 2006 10:13 PM
Start Without Debugging(CTRL F5) 3x slower than Start With Debugging(F5)! lostnewmexico@yahoo.com Microsoft VC .NET 9 22nd Feb 2006 06:14 PM
No Debugging of C# Server-Side Script, but Code-Behind Debugging Works Johann Blake Microsoft ASP .NET 1 5th Jan 2004 03:01 PM
"Start" and "Start Without Debugging" give different results The Last Danish Pastry Microsoft C# .NET 0 23rd Oct 2003 10:24 AM


Features
 

Advertising
 

Newsgroups
 


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