excel vba - Optimising For...Next loops in Select Case -


i have 3 different cases 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

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -