![]() |
Excel Visual Basic - need help to create a loop of filenames
New VBA user here! :o)
I have created a sub which calls individual Excel worksheets and copy certain rows into a new worksheet. Pretty basic. All of the .xls file I am calling are sequential..ie project (1), project (2), project (3), and so on. Instead of listing each workbook individually, can I create some kind of loop which will call up each workbook; like project (#+1).xls? Here is the basics of the sub I am using: Workbooks.Open Filename:=filepath & "project (1).xls" Call copy_rows_into_new Windows("project (1).xls").Activate ActiveWorkbook.Close Workbooks.Open Filename:=filepath & "project (2).xls" Call copy_rows_into_new Windows("project (2).xls").Activate ActiveWorkbook.Close etc. etc. etc. Thanks for any assitance!! |
Excel Visual Basic - need help to create a loop of filenames
untested but something like
for i =1 to 21 Workbooks.Open Filename:="C:\yourfolder\project" & i &".xls" next i -- Don Guillett SalesAid Software "dgates12" wrote in message oups.com... New VBA user here! :o) I have created a sub which calls individual Excel worksheets and copy certain rows into a new worksheet. Pretty basic. All of the .xls file I am calling are sequential..ie project (1), project (2), project (3), and so on. Instead of listing each workbook individually, can I create some kind of loop which will call up each workbook; like project (#+1).xls? Here is the basics of the sub I am using: Workbooks.Open Filename:=filepath & "project (1).xls" Call copy_rows_into_new Windows("project (1).xls").Activate ActiveWorkbook.Close Workbooks.Open Filename:=filepath & "project (2).xls" Call copy_rows_into_new Windows("project (2).xls").Activate ActiveWorkbook.Close etc. etc. etc. Thanks for any assitance!! |
Excel Visual Basic - need help to create a loop of filenames
works great...thanks for the assistance!
|
Excel Visual Basic - need help to create a loop of filenames
glad it helped
-- Don Guillett SalesAid Software "dgates12" wrote in message ups.com... works great...thanks for the assistance! |
All times are GMT +1. The time now is 12:15 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com