Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / December 2007

Tip: Looking for answers? Try searching our database.

Macro unexpectedly jumps to other macros and functions Options

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
MarkM - 06 Dec 2007 12:46 GMT
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/microsoft.public.excel/browse_thread/thread/b9bee
fad029c9e9c/946b03f15071c036?lnk=gst&q=macro+jumps#946b03f15071c036


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
Tim Williams - 07 Dec 2007 03:24 GMT
Is it a UDF that the execution jumps to ?  Changing the worksheet would
quite likely trigger a recalculation...

Tim

> Hello,
>
[quoted text clipped - 64 lines]
> Thank you
> Mark
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.