Good running macros become BOG SLOW
文章推薦指數: 80 %
That should improve the speed. You could also try running a VBA Code Cleaning programme, there are quite a number available on the internet, ... OzGridFreeExcel/VBAHelpForum Forum HELPFORUMS ExcelVBA/Macros ConfusedBob Beginner Points 35 Posts 5 OperatingSystem Windows(x64) ExcelVersion Excel2016 Microsofthasdonemeafavor.Ihavealmost50macrosusedinportfolioevaluation.They’vebeenrunningforyearsandhaveagoodexecutiontrackrecord(executionhistoryislogged).Adailyportfolioassessmentrunwith23macrostakesaboutfiveminutes.UntilFeb4th.Executionbecamebogslow.IaddedApplication.Calculation=xlCalculationManualandApplication.EnableEvents=Falsetotherun-inoneverymacro.Application.ScreenUpdating=Falsewasalreadyinallofthemacros.ScreenUpdatingTrue,CalculationAutomaticandEnableEventsTrueatmacroclose.Someimprovementbut!My23macroruntakes47minutestocompleteinWin11.OfficeHomeandStudent2016.LenovaYogaC740.Nosignofdatacorruptionandthemacroresultsareallspoton.Isthereasolution? royUK SuperModerator ReactionsReceived 807 Points 133,817 Posts 26,394 OperatingSystem Windows(x64) ExcelVersion Office365 It'shardtosaywithoutseeinganexampleofyourcode. rabsofty Student Points 805 Posts 139 OperatingSystem Windows(x64) ExcelVersion Excel2019 yesInoticedabigtimeslowdownwheniupgradedfromoffice2010to2019Ihadtoreadjusthowhowmymacrosdothings.Iconvertedalotofmymacrosthataccessthespreadsheettoarraysandthatdidthetrickforme.IalsohadtoadjustwhereIputmyapplication.screenupdatinginmycode. KjBox OzMVP-SuperModerator ReactionsReceived 210 Points 24,560 Posts 4,742 OperatingSystem Windows(x64) ExcelVersion Office365 Ifyouarecalling22ofthe23macrosfromjustonemacro(orcallingothersfromamacrowhichitselfhadbeencalled)thenyouneedtosetScreenUpdatingtoFalse,CalculationtoManualandEnableEventstoFalseatthestartofthemacrothatcallsthefirstone,andreversethesettingsattheendofthatmacro.RemoveallScreenUpdating,CalculationandEnableEventscodefromalltheothermacros,otherwiseyouareturningthemonandoff23timesinsteadofjustonce!Thatshouldimprovethespeed.YoucouldalsotryrunningaVBACodeCleaningprogramme,therearequiteanumberavailableontheinternet,RibbonCommanderisverygoodasitworksforboth32and64Bitsystems,whereasmostonlyworkon32Bitsystems.Asyouhavealreadydiscovered,convertingasmuchObjectbasedcodeaspossibletoArraybasedcodewillmakeahugespeedimprovement. ConfusedBob Beginner Points 35 Posts 5 OperatingSystem Windows(x64) ExcelVersion Excel2016 Thisismultipleyearreliablecodebyme,adecadeslongcodingprofessional.Mycodeisnotthequestion.Arraysareusedextensivelyandwhereappropriate.AndyesKjBox,thecallingprogramhastheApplication...commandsattheruninandclose,notinthecalledapplicationservicemodules.Theslowdownoccurredinasingledayandineveryoneofthe23macros.Yearslongexecutionexperienceataconsistentperformancelevelvalidatesthecode.SomethingchangedinmyExcel.IinstalledWin11thinkingitwasaWindowsproblem.IusedTheMicrosoftOfficeRepairTool,OnlineoptiontomakesureExcelwasnotcorrupted.Alltonoavail.Fromconsistent5minutesexecutiontimeto47minutesisnotcoding.ItmaybeWindowsissuebutI'mnotaWindowsguru.ConvertingtoWin11wasnohelp.Iremainconfused. KjBox OzMVP-SuperModerator ReactionsReceived 210 Points 24,560 Posts 4,742 OperatingSystem Windows(x64) ExcelVersion Office365 DoyouhaveaccesstoasystemusingOffice2010orOffice365?Itmaybeworthcopyingyourfilestothatsystemandrunningthecode,ifthespeedisbacktowhatitusedtobe,thentheproblemmustbetodowithOffice2019.InthatcaseIsuggestyoureachouttomicrosoftforhelp. ConfusedBob Beginner Points 35 Posts 5 OperatingSystem Windows(x64) ExcelVersion Excel2016 OKThisisstrange.Occaisionalworkbookclosegetshungupon"waitingforotherOLEactiontobecompleted.ExcelOptionsAdvancedGeneralatthebottomofthepageuncheckIgnoreotherapplicationsthatuseDDE.AlsodisabledinfrequentlyusedCOMMaddins.Someimprovement. ConfusedBob Beginner Points 35 Posts 5 OperatingSystem Windows(x64) ExcelVersion Excel2016 KjBoxiscorrect.Thereisanmanagementuserformthatcontrolsexecution.Icanselectasinglemacrooranamedlistofmacrossuchasthepreviouslyreferencedof23macros.Themanagementuserformsetsscreen,calculationandeventsoffduringInitializationandbackonatuserformexit.Eachapplicationmacrotestsduringruninwhetheritisrunningunderthemanagementuserformorastandalonerunandifstandalone,theapplicationmacrodoesitsownscreen,calculationandeventcontrol.I'veattachedarepresentativemacro.Typicalexecutiontime(loggedbythemanagementuserform)forthismacrois4seconds.Itnowrequires30secondstocomplete.I'llsayitagain,thisisnotacodeproblem.Somethingelseisgoingon! KjBox OzMVP-SuperModerator ReactionsReceived 210 Points 24,560 Posts 4,742 OperatingSystem Windows(x64) ExcelVersion Office365 Asyousaycodeyousentlooksgood.Assumingothermacrosaretoo,then,asIsaid,theissuemustlieinusingExcel2019,hopefullyMicrosoftHelpwillbeabletosortyouout. TimFre Beginner Points 5 Posts 1 OperatingSystem Windows(x64) ExcelVersion Office365 Ihadthissameproblem.SomethinghasclearlychangedonMS'sside.Somemacroswhichusedtotakearound30secsweretakinganywherefrom20minsto2.5hours.Thiswasasuddenchangeearlylastweek.However,we'vefoundafix.Oncewedisabledautomaticformularecalculationduringexecutionofthemacro,everythingwentbacktonormal.Ifanything,fasterthanbefore.Atthebeginningofeachfunction: Code Application.Calculation=xlCalculationManual Attheendofeachfunction: Code Application.Calculation=xlCalculationAutomatic Hopethathelps! royUK SuperModerator ReactionsReceived 807 Points 133,817 Posts 26,394 OperatingSystem Windows(x64) ExcelVersion Office365 ThatassumesthatCalculationissettoAutomatic,ifitissettoManualforsomereasonthenyourcodewillchangeittoautomatic.Ithinkit'sbettertocheckCalculationsettingsfirst. Code Subx() lCalc=Application.Calculation WithApplication .Calculation=xlCalculationManual .ScreenUpdating=False .DisplayAlerts=False ''///yourcodehere .Calculation=lCalc .ScreenUpdating=True .DisplayAlerts=True EndWith EndSub DisplayMore ConfusedBob Beginner Points 35 Posts 5 OperatingSystem Windows(x64) ExcelVersion Excel2016 Thereappearstoberesolution.KudostoKjBox.LotsoftimespentwithMicrosoftlevel2.Asmentionedbefore,Win11replacedWin10.ReplacedHomeandStudentwithOffice365.MacroswerepreviouslycodedwithScreenupdatingandCalculation.Eventsarenotmanaged.Muchcodescouringtryingtofindsomekindofirregularity.TahDah!Backtonormalexecution.OnecodingadjustmentwastomovetheApplicationscreenandcalccommandstoimmediatelybeforeandafterApplication.Runinmyexecutionmanagementuserform.AsbestasIcandetermine,it'sacombinationofOffice365andtheexecutionmanagementuserformcodingchange.I'mcallingthisresolved. KjBox OzMVP-SuperModerator ReactionsReceived 210 Points 24,560 Posts 4,742 OperatingSystem Windows(x64) ExcelVersion Office365 Pleasedyougotitresolved. Participatenow! Don’thaveanaccountyet?Registeryourselfnowandbeapartofourcommunity! RegisterYourself Login Share Facebook Twitter Reddit WhatsApp LinkedIn Pinterest XING Tags excelvbamacro Navigation OzGrid Excel/VBAConsultancy OzGridStore Training Freebies Forum UnresolvedThreads ForumRules Dashboard Articles PrivacyPolicy Search Options CurrentLocation OzGridFreeExcel/VBAHelpForum Forum HELPFORUMS ExcelVBA/Macros UserMenu Loginorregister Thissiteusescookies.Bycontinuingtobrowsethissite,youareagreeingtoouruseofcookies. MoreDetails Close
延伸文章資訊
- 1vba excel macros become very slow after the latest update
I have a vba macro that opens an excel file, reads some data, does some calculations and closes t...
- 2Excel VBA Code performance is Extremely Slow
excel - VBA - Code Execution is Extremely Slow - Stack Overflow
- 3Slow VBA Macro | MrExcel Message Board
I've made a macro in vba which is taking quite a bit of time to run (approx 70 secs) and was wond...
- 4Learn How To Use These 7 Tricks To Speed Up ... - YouTube
- 5How to Slow the processing Speed of VBA Code - Mr. Excel
I used Other workbooks, Other Worksheets and multiple formulas and filtrations while the writing ...