LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Better codes to run faster?


Hi all,

My codes belows take more than 2 minutes to run the file. I believe
with better codes it will run faster. Appreciate any advise or
suggestion.

Sub DebtorMaster()

On Error Resume Next
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = False
Range("A7").Select
Selection.RemoveSubtotal
Range("A4").Select
Range("SalesData.xls!Sales").AdvancedFilter Action:=xlFilterCopy, _
CriteriaRange:=Range("A3:I4"), CopyToRange:=Range("A6:K6"),
Unique:=False
Range("A4:I4").Copy

Range("A7").Select
Workbooks.Open Filename:="C:\My Documents\Master.xls"
Sheets("Sheet2").Range("A2").Select
ActiveSheet.Paste
Range("A2").Select
Application.Run "Master.xls!Masterlist"

Range("'Master.xls'!Masteroutput").Select
Selection.Copy
Application.DisplayAlerts = False
ActiveWorkbook.Close
Application.DisplayAlerts = True
Windows("SalesData.xls").Activate
Range("A7").Select
Selection.End(xlDown).Offset(1, 0).Select

ActiveSheet.Paste
Range("A7").Select

Selection.Sort Key1:=Range("E7"), Order1:=xlAscending,
Key2:=Range("F7") _
, Order2:=xlAscending, Key3:=Range("C7"), Order3:=xlAscending, Header:=
_
xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
Selection.Subtotal GroupBy:=5, Function:=xlSum, TotalList:=Array(7, 8,
9), _
Replace:=True, PageBreaks:=True, SummaryBelowData:=True
Selection.AutoFormat Format:=xlRangeAutoFormatSimple

Dim lastrow As String
lastrow = ActiveSheet.Range("E65536").End(xlUp).Row
ActiveSheet.PageSetup.PrintArea = "$A$7:$K$" & lastrow

CreateObject("WScript.Shell").Popup "Please preview the page setting is
correct," + Chr(10) & "then click PRINT to print the Debtors List", 10,
"Printing"

End Sub


--
taych


------------------------------------------------------------------------
taych's Profile: http://www.excelforum.com/member.php...fo&userid=7096
View this thread: http://www.excelforum.com/showthread...hreadid=494342

 
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
can this be done faster? Frank Excel Discussion (Misc queries) 7 August 9th 07 10:02 PM
needs to run faster [email protected] Excel Programming 2 December 2nd 05 09:17 PM
Faster way to do this? Ed Excel Programming 1 November 14th 05 04:27 PM
Can faster CPU+larger/faster RAM significantly speed up recalulati jmk_li Excel Discussion (Misc queries) 2 September 28th 05 10:24 AM
Which one is faster? Syed Zeeshan Haider[_4_] Excel Programming 14 December 4th 03 05:28 PM


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

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

About Us

"It's about Microsoft Excel"