excel vba - Optimising For...Next loops in Select Case -
i have 3 different case
s in bit of code, each of has minor variations on routine revolving around for...next
loop. question is, there difference in efficiency , speed depending on how nest them?
in other words, is:
select case sposition case = "first" j = 17 65 [do stuff] next j case = "middle" j = 17 65 [do stuff] next j case = "last" j = 17 65 [do stuff] next j end select
...any more or less efficient than:
for j = 17 65 select case sposition case = "first" [do stuff] case = "middle" [do stuff] case = "last" [do stuff] end select next j
more of question codereview so, regardless, dependent on intending loops. in first situation, have condition , loop through data in accordance result of condition, doing same thing data. in second case, re-checking condition each time loop runs. if think different things happening loop runs (different cases being selected), need use second variation, if checked condition not changing, first option faster, condition checked once loop
Comments
Post a Comment