TampaRocks
Technical User
Don't know if that's the right way to put it, but hopefully I can describe it better. I have a directory with 42 spreadsheets in it. I have a script that will open a spreadsheet (in xlsm format), save it out as an xlsx file, then save/close. Here's what I have...
For i = 6 to 9
Set objExcel = CreateObject("Excel.Application")
objExcel.Workbooks.Open "C:\Temp\0508_00" & i & ".xlsm"
objExcel.ActiveWorkbook.Saved = True
objExcel.ActiveWindow.Close
objExcel.Application.Quit
Set objExcel = Nothing
Next
Here's my problem. I don't need to do all 42. Also, the filename of the spreadsheets have to be padded with 0's.
Here's what I think I need. I'm thinking that I can start my loop with 1 and run through to 42, but verify each number against a series of numbers to skip. So if "i" equals a number that is in a set, then "i" skips to the next number, if not, it runs through the rest of the program. It will keep going until it finishes the 42nd spreadsheet.
Also, as I mentioned, the filenames are padded with zero's. So how do I change the file name to go from 0508_00#.xlsm to 0508_0##,xlsm when I get to "i"=10?
For i = 6 to 9
Set objExcel = CreateObject("Excel.Application")
objExcel.Workbooks.Open "C:\Temp\0508_00" & i & ".xlsm"
objExcel.ActiveWorkbook.Saved = True
objExcel.ActiveWindow.Close
objExcel.Application.Quit
Set objExcel = Nothing
Next
Here's my problem. I don't need to do all 42. Also, the filename of the spreadsheets have to be padded with 0's.
Here's what I think I need. I'm thinking that I can start my loop with 1 and run through to 42, but verify each number against a series of numbers to skip. So if "i" equals a number that is in a set, then "i" skips to the next number, if not, it runs through the rest of the program. It will keep going until it finishes the 42nd spreadsheet.
Also, as I mentioned, the filenames are padded with zero's. So how do I change the file name to go from 0508_00#.xlsm to 0508_0##,xlsm when I get to "i"=10?