Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 152
Default Rerunning Macro takes longer after each consecutive use....Why

Hi Dave,
Did all the suggestions but no changes.

"Dave Peterson" wrote:

The columnwidths stuff was germane to the other post--I should have taken that
out before I pasted.

Did you try the other suggestions.

MikeZz wrote:

Hi Dave,
I don't do any column width changing. Just paste values from my workbook to
the customer workbook. There aren't a massive amount of formulas so I don't
think it's the calculation udpate that's causing the problem. In addition,
each time I run the macro, it's just re-copying what the previous macro had
done so it's not doing anything different.

Thanks for the help.

"Dave Peterson" wrote:

(Saved from a previous post)

I would think that it would depend a lot on what your macro does--if it
inserts/deletes rows or columns, then...

Do you see the dotted lines that you get after you do a print or print preview?

If you do
Tools|Options|view tab|uncheck display page breaks

does the run time go back to normal?

Since you're changing columnwidths, excel could be figuring out where those
dotted lines go.

You may want to do something like:

Option Explicit
Sub testme()

Dim CalcMode As Long
Dim ViewMode As Long

Application.ScreenUpdating = False

CalcMode = Application.Calculation
Application.Calculation = xlCalculationManual

ViewMode = ActiveWindow.View
ActiveWindow.View = xlNormalView

ActiveSheet.DisplayPageBreaks = False

'do the work

'put things back to what they were
Application.Calculation = CalcMode
ActiveWindow.View = ViewMode

End Sub

Being in View|PageBreak Preview mode can slow macros down, too.

MikeZz wrote:

I have a timer in a VBA sub that copies data from one workbook to a series of
customer forms.

I've noticed that each consecutive time I re-run the same exact macro with
the same data, it takes a couple seconds longer. If I completely close
excel, it seems run faster, then get slower again.

Looking at windows task manager, my memory usage isn't going up so I'm
wondering what I'm doing wrong.

1st run: 6 sec
2nd run: 7 sec
3rd run: 8 sec
4th run: 10 sec
5th run: 12 sec
6th run: 13 sec
7th run: 14 sec

This is the first time I've done the following and I don't have problems
with any other macros taking longer:
1. Use Application.EnableEvents = False
2. Reference named ranges more instead of load data into array first.

Thanks, MikeZz

--

Dave Peterson


--

Dave Peterson

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Rerunning Macro takes longer after each consecutive use....Why

Maybe you could add a few strategically placed:
Debug.print "Step ###: " & now
into your code.

Then you may find out what area is taking the most time and see if you can
improve that area?????

MikeZz wrote:

Hi Dave,
Did all the suggestions but no changes.

"Dave Peterson" wrote:

The columnwidths stuff was germane to the other post--I should have taken that
out before I pasted.

Did you try the other suggestions.

MikeZz wrote:

Hi Dave,
I don't do any column width changing. Just paste values from my workbook to
the customer workbook. There aren't a massive amount of formulas so I don't
think it's the calculation udpate that's causing the problem. In addition,
each time I run the macro, it's just re-copying what the previous macro had
done so it's not doing anything different.

Thanks for the help.

"Dave Peterson" wrote:

(Saved from a previous post)

I would think that it would depend a lot on what your macro does--if it
inserts/deletes rows or columns, then...

Do you see the dotted lines that you get after you do a print or print preview?

If you do
Tools|Options|view tab|uncheck display page breaks

does the run time go back to normal?

Since you're changing columnwidths, excel could be figuring out where those
dotted lines go.

You may want to do something like:

Option Explicit
Sub testme()

Dim CalcMode As Long
Dim ViewMode As Long

Application.ScreenUpdating = False

CalcMode = Application.Calculation
Application.Calculation = xlCalculationManual

ViewMode = ActiveWindow.View
ActiveWindow.View = xlNormalView

ActiveSheet.DisplayPageBreaks = False

'do the work

'put things back to what they were
Application.Calculation = CalcMode
ActiveWindow.View = ViewMode

End Sub

Being in View|PageBreak Preview mode can slow macros down, too.

MikeZz wrote:

I have a timer in a VBA sub that copies data from one workbook to a series of
customer forms.

I've noticed that each consecutive time I re-run the same exact macro with
the same data, it takes a couple seconds longer. If I completely close
excel, it seems run faster, then get slower again.

Looking at windows task manager, my memory usage isn't going up so I'm
wondering what I'm doing wrong.

1st run: 6 sec
2nd run: 7 sec
3rd run: 8 sec
4th run: 10 sec
5th run: 12 sec
6th run: 13 sec
7th run: 14 sec

This is the first time I've done the following and I don't have problems
with any other macros taking longer:
1. Use Application.EnableEvents = False
2. Reference named ranges more instead of load data into array first.

Thanks, MikeZz

--

Dave Peterson


--

Dave Peterson


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 152
Default Rerunning Macro takes longer after each consecutive use....Why

That's a good idea.
Just curious though, I haven't used the .print since college maybe 15 years
ago. Where does it print to? ie... where does the log data go?

Thanks,

"Dave Peterson" wrote:

Maybe you could add a few strategically placed:
Debug.print "Step ###: " & now
into your code.

Then you may find out what area is taking the most time and see if you can
improve that area?????

MikeZz wrote:

Hi Dave,
Did all the suggestions but no changes.

"Dave Peterson" wrote:

The columnwidths stuff was germane to the other post--I should have taken that
out before I pasted.

Did you try the other suggestions.

MikeZz wrote:

Hi Dave,
I don't do any column width changing. Just paste values from my workbook to
the customer workbook. There aren't a massive amount of formulas so I don't
think it's the calculation udpate that's causing the problem. In addition,
each time I run the macro, it's just re-copying what the previous macro had
done so it's not doing anything different.

Thanks for the help.

"Dave Peterson" wrote:

(Saved from a previous post)

I would think that it would depend a lot on what your macro does--if it
inserts/deletes rows or columns, then...

Do you see the dotted lines that you get after you do a print or print preview?

If you do
Tools|Options|view tab|uncheck display page breaks

does the run time go back to normal?

Since you're changing columnwidths, excel could be figuring out where those
dotted lines go.

You may want to do something like:

Option Explicit
Sub testme()

Dim CalcMode As Long
Dim ViewMode As Long

Application.ScreenUpdating = False

CalcMode = Application.Calculation
Application.Calculation = xlCalculationManual

ViewMode = ActiveWindow.View
ActiveWindow.View = xlNormalView

ActiveSheet.DisplayPageBreaks = False

'do the work

'put things back to what they were
Application.Calculation = CalcMode
ActiveWindow.View = ViewMode

End Sub

Being in View|PageBreak Preview mode can slow macros down, too.

MikeZz wrote:

I have a timer in a VBA sub that copies data from one workbook to a series of
customer forms.

I've noticed that each consecutive time I re-run the same exact macro with
the same data, it takes a couple seconds longer. If I completely close
excel, it seems run faster, then get slower again.

Looking at windows task manager, my memory usage isn't going up so I'm
wondering what I'm doing wrong.

1st run: 6 sec
2nd run: 7 sec
3rd run: 8 sec
4th run: 10 sec
5th run: 12 sec
6th run: 13 sec
7th run: 14 sec

This is the first time I've done the following and I don't have problems
with any other macros taking longer:
1. Use Application.EnableEvents = False
2. Reference named ranges more instead of load data into array first.

Thanks, MikeZz

--

Dave Peterson


--

Dave Peterson


--

Dave Peterson

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Rerunning Macro takes longer after each consecutive use....Why

It prints to the VBE's immediate window.

You can see it by hitting ctrl-g or View|immediate window (when you're in the
VBE).

MikeZz wrote:

That's a good idea.
Just curious though, I haven't used the .print since college maybe 15 years
ago. Where does it print to? ie... where does the log data go?

Thanks,

"Dave Peterson" wrote:

Maybe you could add a few strategically placed:
Debug.print "Step ###: " & now
into your code.

Then you may find out what area is taking the most time and see if you can
improve that area?????

MikeZz wrote:

Hi Dave,
Did all the suggestions but no changes.

"Dave Peterson" wrote:

The columnwidths stuff was germane to the other post--I should have taken that
out before I pasted.

Did you try the other suggestions.

MikeZz wrote:

Hi Dave,
I don't do any column width changing. Just paste values from my workbook to
the customer workbook. There aren't a massive amount of formulas so I don't
think it's the calculation udpate that's causing the problem. In addition,
each time I run the macro, it's just re-copying what the previous macro had
done so it's not doing anything different.

Thanks for the help.

"Dave Peterson" wrote:

(Saved from a previous post)

I would think that it would depend a lot on what your macro does--if it
inserts/deletes rows or columns, then...

Do you see the dotted lines that you get after you do a print or print preview?

If you do
Tools|Options|view tab|uncheck display page breaks

does the run time go back to normal?

Since you're changing columnwidths, excel could be figuring out where those
dotted lines go.

You may want to do something like:

Option Explicit
Sub testme()

Dim CalcMode As Long
Dim ViewMode As Long

Application.ScreenUpdating = False

CalcMode = Application.Calculation
Application.Calculation = xlCalculationManual

ViewMode = ActiveWindow.View
ActiveWindow.View = xlNormalView

ActiveSheet.DisplayPageBreaks = False

'do the work

'put things back to what they were
Application.Calculation = CalcMode
ActiveWindow.View = ViewMode

End Sub

Being in View|PageBreak Preview mode can slow macros down, too.

MikeZz wrote:

I have a timer in a VBA sub that copies data from one workbook to a series of
customer forms.

I've noticed that each consecutive time I re-run the same exact macro with
the same data, it takes a couple seconds longer. If I completely close
excel, it seems run faster, then get slower again.

Looking at windows task manager, my memory usage isn't going up so I'm
wondering what I'm doing wrong.

1st run: 6 sec
2nd run: 7 sec
3rd run: 8 sec
4th run: 10 sec
5th run: 12 sec
6th run: 13 sec
7th run: 14 sec

This is the first time I've done the following and I don't have problems
with any other macros taking longer:
1. Use Application.EnableEvents = False
2. Reference named ranges more instead of load data into array first.

Thanks, MikeZz

--

Dave Peterson


--

Dave Peterson


--

Dave Peterson


--

Dave Peterson
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
My excel macro recorder no longer shows up when recording macro jack Excel Discussion (Misc queries) 1 February 5th 07 09:31 PM
My excel macro recorder no longer shows up when recording macro jack Excel Discussion (Misc queries) 3 February 5th 07 08:22 PM
how do i add time to see how long my macro takes to run ernestgoh[_6_] Excel Programming 2 July 16th 06 11:05 AM
Double-clicking cell with =A1 no longer takes you to A1 in v2003? GoDario27 Excel Discussion (Misc queries) 6 August 16th 05 03:31 PM
Counting how long a Macro takes to run Diane Alsing Excel Programming 2 February 7th 05 05:41 PM


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