Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default excel runs slow until closed and reopened

I have a macro that copys a lot of formulars then pastes the values.
When it has finished "Calculate" shows in task bar even after recalc
and spread sheet runs slow.
If i save and close spreadsheet it runs fine when reopened untill
macro is run again.

Code I run

LongLine = LongLine _
+ LongerLine

UserForm1.Show vbModeless

UserForm1.Label4 = "Processing Please Wait..."
UserForm1.Label1.BackStyle = fmBackStyleTransparent
UserForm1.count.Value = 1

UserForm1.Repaint


Application.ScreenUpdating = False
Application.EnableEvents = False
Application.Calculation = xlCalculationManual 'added 12th April

ActiveSheet.Unprotect ("sidata")

Range("D8:H8").Select
Selection.AutoFilter
Selection.AutoFilter

Range("B9:D446").Select
Range("D446").Activate
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False

UserForm1.count.Value = 2
UserForm1.Repaint

Range("I9:BW446").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False

UserForm1.count.Value = 4
UserForm1.Repaint

Selection.AutoFilter Field:=5, Criteria1:="O-STK"
Range("I449:BW449").Select
Range("BW449").Activate
Application.CutCopyMode = False
Selection.Copy
Range("I11:BW446").Select
Range("I446").Activate
ActiveSheet.Paste

UserForm1.count.Value = 6
UserForm1.Repaint

Selection.AutoFilter Field:=5
Range("B9:D446").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Range("F447").Select

UserForm1.count.Value = 7
UserForm1.Repaint

Selection.AutoFilter Field:=5
ActiveWindow.ScrollRow = 9
ActiveWindow.ScrollColumn = 7
Range("G1").Select
ActiveCell.FormulaR1C1 = "FAST MODE - No Update"

ActiveSheet.Protect ("sidata"), DrawingObjects:=True,
Contents:=True, Scenarios:=True _
, AllowFiltering:=True

UserForm1.count.Value = 8
UserForm1.Repaint

Application.Calculation = xlCalculationAutomatic 'added 12th April
Application.ScreenUpdating = True
Application.EnableEvents = True

UserForm1.Label1.BackStyle = fmBackStyleOpaque
UserForm1.Label1.BackColor = vbGreen


UserForm1.count.Value = 10
UserForm1.Label4 = "Complete"
UserForm1.Repaint
Application.Wait Now + TimeValue("0:0:04")
UserForm1.count.Value = 0
UserForm1.Repaint
UserForm1.Hide

UserForm1.Hide

'Release memory
Set wSheet = Nothing


End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default excel runs slow until closed and reopened


You need to unload the user form when you are done with it...
Unload UserForm1
Also, there is no need to hide the form twice.
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware
(Excel Add-ins / Excel Programming)



"Sliman"
wrote in message
I have a macro that copys a lot of formulars then pastes the values.
When it has finished "Calculate" shows in task bar even after recalc
and spread sheet runs slow.
If i save and close spreadsheet it runs fine when reopened untill
macro is run again.

Code I run

LongLine = LongLine _
+ LongerLine

UserForm1.Show vbModeless

UserForm1.Label4 = "Processing Please Wait..."
UserForm1.Label1.BackStyle = fmBackStyleTransparent
UserForm1.count.Value = 1

UserForm1.Repaint


Application.ScreenUpdating = False
Application.EnableEvents = False
Application.Calculation = xlCalculationManual 'added 12th April

ActiveSheet.Unprotect ("sidata")

Range("D8:H8").Select
Selection.AutoFilter
Selection.AutoFilter

Range("B9:D446").Select
Range("D446").Activate
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False

UserForm1.count.Value = 2
UserForm1.Repaint

Range("I9:BW446").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False

UserForm1.count.Value = 4
UserForm1.Repaint

Selection.AutoFilter Field:=5, Criteria1:="O-STK"
Range("I449:BW449").Select
Range("BW449").Activate
Application.CutCopyMode = False
Selection.Copy
Range("I11:BW446").Select
Range("I446").Activate
ActiveSheet.Paste

UserForm1.count.Value = 6
UserForm1.Repaint

Selection.AutoFilter Field:=5
Range("B9:D446").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Range("F447").Select

UserForm1.count.Value = 7
UserForm1.Repaint

Selection.AutoFilter Field:=5
ActiveWindow.ScrollRow = 9
ActiveWindow.ScrollColumn = 7
Range("G1").Select
ActiveCell.FormulaR1C1 = "FAST MODE - No Update"

ActiveSheet.Protect ("sidata"), DrawingObjects:=True,
Contents:=True, Scenarios:=True _
, AllowFiltering:=True

UserForm1.count.Value = 8
UserForm1.Repaint

Application.Calculation = xlCalculationAutomatic 'added 12th April
Application.ScreenUpdating = True
Application.EnableEvents = True

UserForm1.Label1.BackStyle = fmBackStyleOpaque
UserForm1.Label1.BackColor = vbGreen


UserForm1.count.Value = 10
UserForm1.Label4 = "Complete"
UserForm1.Repaint
Application.Wait Now + TimeValue("0:0:04")
UserForm1.count.Value = 0
UserForm1.Repaint
UserForm1.Hide

UserForm1.Hide

'Release memory
Set wSheet = Nothing


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
Excel Sheet Suddenly Runs Slow Ed O'Brien Excel Discussion (Misc queries) 7 April 2nd 10 02:48 AM
Excel runs slow coco w. Excel Worksheet Functions 1 February 19th 10 06:50 AM
Excel macro in 2007 runs extremely slow Acie Excel Discussion (Misc queries) 3 March 3rd 09 04:22 PM
Excel Runs Slow Jason Zischke Excel Discussion (Misc queries) 0 March 14th 07 02:19 AM
2003 Excel VBA on XP runs very slow vs Win/Office 2000 - why? Quadra Excel Programming 7 October 6th 04 11:09 PM


All times are GMT +1. The time now is 02:53 AM.

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"