Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 81
Default why does the execution jump to another procedure?

Hi, I have the following code. As I push F8 to execute manually, after the Insert row, it jumps to another procedure, skips around some of those lines of code, then comes back to execute the last line?

I have noticed this pattern in some other spreadsheet VBA as well.

What am I doing wrong? Thanks, Harold


Private Sub InsertRow()
Dim myRow As Long

myRow = ActiveCell.Row
Do Until Cells(myRow, 2) < Cells(myRow + 1, 2)
myRow = myRow + 1
Loop
Rows(myRow).Insert
Rows(ActiveCell.Row).Select

End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 53
Default why does the execution jump to another procedure?


In the VBA project window, double click on the worksheet object to see if
there is a "worksheet_change" sub. Every time you make a change to the
worksheet this will execute. In the code below, the insert action qualifies
as a worksheet change event.

If you can determine that the change event code is not necessary to current
intended functioning of the file, then you can just delete it. Otherwise,
you'll want to be sure that any new routines you add will work with it in a
predictable way.

"Harold Good" wrote:

Hi, I have the following code. As I push F8 to execute manually, after the Insert row, it jumps to another procedure, skips around some of those lines of code, then comes back to execute the last line?

I have noticed this pattern in some other spreadsheet VBA as well.

What am I doing wrong? Thanks, Harold


Private Sub InsertRow()
Dim myRow As Long

myRow = ActiveCell.Row
Do Until Cells(myRow, 2) < Cells(myRow + 1, 2)
myRow = myRow + 1
Loop
Rows(myRow).Insert
Rows(ActiveCell.Row).Select

End Sub

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,049
Default why does the execution jump to another procedure?

if there is a sheet change event, you can disable it using using the
Application.EnableEvents method ..



Private Sub InsertRow()
Dim myRow As Long

Application.EnableEvents = False

myRow = ActiveCell.Row
Do Until Cells(myRow, 2) < Cells(myRow + 1, 2)
myRow = myRow + 1
Loop
Rows(myRow).Insert
Rows(ActiveCell.Row).Select

Application.EnableEvents = True

End Sub




"slarbie" wrote in message
...

In the VBA project window, double click on the worksheet object to see if
there is a "worksheet_change" sub. Every time you make a change to the
worksheet this will execute. In the code below, the insert action
qualifies
as a worksheet change event.

If you can determine that the change event code is not necessary to
current
intended functioning of the file, then you can just delete it. Otherwise,
you'll want to be sure that any new routines you add will work with it in
a
predictable way.

"Harold Good" wrote:

Hi, I have the following code. As I push F8 to execute manually, after
the Insert row, it jumps to another procedure, skips around some of those
lines of code, then comes back to execute the last line?

I have noticed this pattern in some other spreadsheet VBA as well.

What am I doing wrong? Thanks, Harold


Private Sub InsertRow()
Dim myRow As Long

myRow = ActiveCell.Row
Do Until Cells(myRow, 2) < Cells(myRow + 1, 2)
myRow = myRow + 1
Loop
Rows(myRow).Insert
Rows(ActiveCell.Row).Select

End Sub


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 81
Default why does the execution jump to another procedure?

Thank you very much, I had no idea why this was happening on some of my
spreadsheets!
Harold


"slarbie" wrote in message
...

In the VBA project window, double click on the worksheet object to see if
there is a "worksheet_change" sub. Every time you make a change to the
worksheet this will execute. In the code below, the insert action
qualifies
as a worksheet change event.

If you can determine that the change event code is not necessary to
current
intended functioning of the file, then you can just delete it. Otherwise,
you'll want to be sure that any new routines you add will work with it in
a
predictable way.

"Harold Good" wrote:

Hi, I have the following code. As I push F8 to execute manually, after
the Insert row, it jumps to another procedure, skips around some of those
lines of code, then comes back to execute the last line?

I have noticed this pattern in some other spreadsheet VBA as well.

What am I doing wrong? Thanks, Harold


Private Sub InsertRow()
Dim myRow As Long

myRow = ActiveCell.Row
Do Until Cells(myRow, 2) < Cells(myRow + 1, 2)
myRow = myRow + 1
Loop
Rows(myRow).Insert
Rows(ActiveCell.Row).Select

End Sub



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 81
Default why does the execution jump to another procedure?

Thank you, very helpful!
Harold


"Patrick Molloy" wrote in message
...
if there is a sheet change event, you can disable it using using the
Application.EnableEvents method ..



Private Sub InsertRow()
Dim myRow As Long

Application.EnableEvents = False

myRow = ActiveCell.Row
Do Until Cells(myRow, 2) < Cells(myRow + 1, 2)
myRow = myRow + 1
Loop
Rows(myRow).Insert
Rows(ActiveCell.Row).Select

Application.EnableEvents = True

End Sub




"slarbie" wrote in message
...

In the VBA project window, double click on the worksheet object to see if
there is a "worksheet_change" sub. Every time you make a change to the
worksheet this will execute. In the code below, the insert action
qualifies
as a worksheet change event.

If you can determine that the change event code is not necessary to
current
intended functioning of the file, then you can just delete it.
Otherwise,
you'll want to be sure that any new routines you add will work with it in
a
predictable way.

"Harold Good" wrote:

Hi, I have the following code. As I push F8 to execute manually, after
the Insert row, it jumps to another procedure, skips around some of
those lines of code, then comes back to execute the last line?

I have noticed this pattern in some other spreadsheet VBA as well.

What am I doing wrong? Thanks, Harold


Private Sub InsertRow()
Dim myRow As Long

myRow = ActiveCell.Row
Do Until Cells(myRow, 2) < Cells(myRow + 1, 2)
myRow = myRow + 1
Loop
Rows(myRow).Insert
Rows(ActiveCell.Row).Select

End Sub




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
Time the Execution Speed of Procedure in Milliseconds RyanH Excel Programming 1 August 24th 08 10:44 PM
Array retained in memory despite procedure execution ended Edmund Excel Programming 1 July 13th 07 06:57 AM
Blank Message Box after procedure execution [email protected] Excel Programming 7 June 1st 07 01:13 PM
How to jump from a Form procedure to a Workbook or Module procedure? T. Erkson Excel Programming 4 January 25th 07 07:15 PM
Function/Procedure dependence & order of execution Jon L Excel Programming 1 October 3rd 04 10:06 AM


All times are GMT +1. The time now is 02:29 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"