Excel runs very slow (with VBA) -
i have userform several drop-down lists, populated via vba macro. happens right @ beginning, on opening workbook.
once load done, workbook becomes slow. scrolling 1 cell causes noticeable lag, despite not having running macro.
on opening workbook, load() function called preps userform.
the userform has ~25 dropdown lists, populated separate sheet ("menu") stores values each of these dropdowns in separate column. "menu" sheet filled via load() function calls 1 of 2 menuquery() routines.
one of these pick distinct values columns in dbf file, other lists down options based on list in question.
snippets load() subroutine :
sub load() application.screenupdating = true dim mysht, datasht worksheet set mysht = sheets("dashboard") set datasht = sheets("menu") mysht.visible = xlsheetvisible mysht.activate datasht.visible = xlsheetvisible datasht.activate activesheet.range("a1:iv2000").select selection.clearcontents range("a1").select call menuquery("a", "type", "hh", "cmbbox1") call menuquery1("b", "flow", "flow", "cmbbox2") . '25 similar calls . datasht.visible = xlsheetveryhidden . .'hide sheets . sheets("triggers").visible = xlveryhidden sheets("actions").visible = xlveryhidden mysht.visible = xlsheetvisible mysht.activate end sub
what i've tried:
- have tried commenting out menuquery() functions , problem persists. guess isnt problem here
- tried application.screenupdating=false in beginning of function, no change
- in fact, tried not calling load() function, doesn't seem either!
if have excel vba macro code runs slow, chances it's caused excel having recalculate @ each line of code. deleting rows 1 of many things can become painfully slow. can overcome switching excel manual calculation before code runs. aware if code bugs out, , have no error trap, workbook left in manual calculation , no designed spreadsheet should ever used calculation in manual. if ever advice switch excel manual calculation prevent slow saving, closing , data entry...run fast! band aid approach rather addressing underlying cause. if run excel workbook in manual calculation it's matter of time before non-calculated data read off!
Comments
Post a Comment