Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Macro unexpectedly jumps to other macros and functions Options

Hello,

I saw another post dated Nov 2004 where Dave Peterson discussed using
a global variable to overcome the problem. Refer
http://groups.google.com/group/micro...03f1507 1c036

I have encountered this issue a number of times and would like to know
what causes it.
Office 2003 / Win XP SP2

My code is outlined below;

Sub Macro1()

Dim iRow as Integer

Sheets("Sheet1").Select
Range("A1").Select

'Delete all rows until we get to a "header" row in which Column A has
the text "PO #"
While ActiveCell < "PO #"
ActiveCell.EntireRow.Delete
Wend

While ActiveCell < "End_Data"
So when I get to a line that has PO #, I move down one line and test
for the first three characters = "AUS"
If Left(ActiveCell,3) = "AUS" Then
iRow = iRow + 1
Call FormatReport1(iRow)
Call FormatReport2(iRow)

Else
ActiveCell.EntireRow.Delete
End If
Wend


End Sub


Sub FormatReport1(iRec as integer)

I need to copy from the current row, column offsets 7, 8, 9, 4, 5 and
0 to another worksheet in this workbook.

Dim strOut as String
strOut = ActiveCell(0,7) & "," & ActiveCell(0,8) & "," &
ActiveCell(0,9) & "," & ActiveCell(0,4) & "," & ActiveCell(0,5) & ","
& ActiveCell
Sheets("Report1").Select
Range("A1").Offset(iRec, 0) = strOut '
<---------------- This line also causes the control to jump.
Sheets("Sheet1").Select

End Sub


After executing the Delete statement in the first While loop, the
yellow highlight jumps to a Function Definition statement in another
module of this Workbook.

If I change the delete statement to ActiveCell.Offset(1,0).Activate,
then it works as expected.


Any explanations as to why this behaviour occurs would be greatly
appreciated.

Thank you
Mark




  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,588
Default Macro unexpectedly jumps to other macros and functions Options

Is it a UDF that the execution jumps to ? Changing the worksheet would
quite likely trigger a recalculation...

Tim


"MarkM" wrote in message
...
Hello,

I saw another post dated Nov 2004 where Dave Peterson discussed using
a global variable to overcome the problem. Refer
http://groups.google.com/group/micro...03f1507 1c036

I have encountered this issue a number of times and would like to know
what causes it.
Office 2003 / Win XP SP2

My code is outlined below;

Sub Macro1()

Dim iRow as Integer

Sheets("Sheet1").Select
Range("A1").Select

'Delete all rows until we get to a "header" row in which Column A has
the text "PO #"
While ActiveCell < "PO #"
ActiveCell.EntireRow.Delete
Wend

While ActiveCell < "End_Data"
So when I get to a line that has PO #, I move down one line and test
for the first three characters = "AUS"
If Left(ActiveCell,3) = "AUS" Then
iRow = iRow + 1
Call FormatReport1(iRow)
Call FormatReport2(iRow)

Else
ActiveCell.EntireRow.Delete
End If
Wend


End Sub


Sub FormatReport1(iRec as integer)

I need to copy from the current row, column offsets 7, 8, 9, 4, 5 and
0 to another worksheet in this workbook.

Dim strOut as String
strOut = ActiveCell(0,7) & "," & ActiveCell(0,8) & "," &
ActiveCell(0,9) & "," & ActiveCell(0,4) & "," & ActiveCell(0,5) & ","
& ActiveCell
Sheets("Report1").Select
Range("A1").Offset(iRec, 0) = strOut '
<---------------- This line also causes the control to jump.
Sheets("Sheet1").Select

End Sub


After executing the Delete statement in the first While loop, the
yellow highlight jumps to a Function Definition statement in another
module of this Workbook.

If I change the delete statement to ActiveCell.Offset(1,0).Activate,
then it works as expected.


Any explanations as to why this behaviour occurs would be greatly
appreciated.

Thank you
Mark






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
No Menu functions/options when right clicking mouse Rob Excel Discussion (Misc queries) 1 April 27th 09 12:51 PM
Sub unexpectedly jumps to another sub Jeff Wright[_2_] Excel Programming 3 August 26th 06 01:48 PM
other options to functions which cannot modify contents? James Cornthwaite Excel Programming 1 June 5th 06 12:46 AM
using excel functions in a macro - not familiar with macros at all James Cornthwaite Excel Programming 6 May 14th 06 05:36 PM
Macro unexpectedly jumps to other macros and functions Jeff Wright[_2_] Excel Programming 3 November 25th 04 01:47 PM


All times are GMT +1. The time now is 07:24 PM.

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

About Us

"It's about Microsoft Excel"