I have a set of files, which I want to loop through file names: budget 2015, budget 2016, budget 2017 up to 2022. I loop through them using DR
Workbook path = Dir used as dull openWb ("C: \ Pathofile \ Budget 20 ?? xlsx") '? Dial Wildcard FilePath = "C: \ Pathfile \" 'The name of the dial return file is not the whole path, myHeadings = Split ("January, February, Tuesday, April, Major, Juni, July, August, September, October, November, December ",", ") Jammu = 0 while Lane (Path)> 0 = i = 0 If Dir = "Budget 2014.xlsx" then j = 0 and for this I = 0 to UBound (myHeadings) OpenWb set = workbooks. Open (file path and path) Mailbox lane (path) OpenWs = Set up openWb.Sheets (MyHeadings (i)) if openWs.Range ("C34") = 0 then current Wb.Sheets ("Indata"). Room (70, i + 27 + 12 * (j + 1)). Value = "" other current Wb .set ("Indet"). Cell (70, i + 27 + 12 * (J + 1)) value = open. The limit ("C 34") end if the next I end path if = path j = j + 1 loop problem is that there is also a file named budget 2014, in the path of filtrate, through which i do not have to loop because 1) it is not necessary The value is already counted and 2) since it screws my index in the loop has updated my code but I use the msgbox (path) for = 0 ... Loop "Budget 2014.xlsx" which I did not want to loop, and so it's my J. Subscript Gath gives "bad"
You can use the year method. String file path = "C: \ pathtofile \" yearNo = year (date ()) path = Dir ("C: \"), such as some
form of slow OpenWb workbook In, Pathfile \ Budget "& amp; Year No & amp; .xlsx ") while the lane (path)> set set openblb = workbook.open (file path and path) 'dial only gives the file name' some things are doing year, none = year none + 1 path = Dir ("C: \ Pathophile \ Budget" and Year Number and ".xlsx") Loop
No comments:
Post a Comment