Originally Posted by
Kimbertha
Hello All:
How can I modify the following code to:
1) Specify a tab and range
2) Give the imported file the same name as the source (minus the .XLS extension)
The parts in red show where I have figured out how to successfully modify.
The VBA code below works great, except it imports the first tab of a multi-tab workbook. The first tab on my 1,200+ bookbooks contains instructions, not the data that I want.
Thanks for any suggestions!
Kim
to specify a tab in excel, you can use either of the following code lines:
Code:
workbook.worksheets("sheet name").range("start cell", "end cell")
or:
Code:
workbook.worksheets(sheet index integer).range("start cell", "end cell")
sheet indexes in excel are base-1. in other words, there is no sheet #0. the sheets are indexed, in order, based on their created date, NOT their left-to-right appearance in the workbook.
to give a FILE or a TABLE the same name as the imported data? if you're talking table, use access VBA's docmd() method. simple as that. and I might be mistaken, but isn't there an arg in the transferspreadsheet() method where you can tell the routine what range or even SHEET to import? if there is, put the sheet name in there first. try that. I haven't done this work in a while, but it's none-the-less still not that difficult, or shouldn't be...