excel - vba find file path using increment? -


i trying use following vba code find file path of file:

lets have file called text.xlsx

this stored in

g:\folder\1. 2017      or       g:\folder\2. 2017      or      g:\folder\3. 2017      etc 

so trying use loop check numbers 1 10

to ensure path found.

sub planneropen() dim integer = 1 10 path = "g:\folder\" & & ". " & year(date) & "\" msgbox path & "*.xlsx" = + 1 next  end sub 

this seems produce numbers 1, 3, 5 , 9.

am doing wrong? please can show me going wrong?

the for = 1 10 line start of loop, setting i 1 , increment 1 on each iteration (unless otherwise specified step) until reaches 10.

your loop starts on 1, creates msgbox 1 manually increase i 2 line i = + 1. returns start of loop , default increment i again 1 per design, setting 3.

remove manual i = + 1 incrementation , allow loop you.


Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -