By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,510 Members | 1,477 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,510 IT Pros & Developers. It's quick & easy.

more the one range with DoCmd.TransferSpreadsheet

P: 1
Hi All,
I'm trying to import an Excel sheet, but with more the one rang, couse the columns aint sequence.
for example:
DoCmd.TransferSpreadsheet acImport, , "DailyRprzntvRpt", _
Application.CurrentProject.Path & "\DailyRprzntvRpt.xls", True, "(A1:C18, F1:J18)"

I'm getting an error, that saies that the range is not recognized by Access.

Any idea?
Jan 12 '09 #1
Share this Question
Share on Google+
2 Replies


ADezii
Expert 5K+
P: 8,601
@amir369
I'm not 100% sure on this one, but I think you can only perform the Import on a single, specified Range as in:
Expand|Select|Wrap|Line Numbers
  1. DoCmd.TransferSpreadsheet acImport, , "DailyRprzntvRpt", _
  2. Application.CurrentProject.Path & "\DailyRprzntvRpt.xls", True, "A1:C18"
Jan 12 '09 #2

Expert Mod 2.5K+
P: 2,545
ADezii is spot-on - you cannot use a split range with TransferSpreadsheet under any circumstances. If you look up the the help information for the TransferSpreadsheet action it is clear about what a range is:

Range
The range of cells to import or link. Leave this argument blank to import or link the entire spreadsheet. You can type the name of a range in the spreadsheet or specify the range of cells to import or link, such as A1:E25 (note that the A1..E25 syntax does not work in Access 97 or later). If you are importing from or linking to an Excel version 5.0 or later spreadsheet, you can prefix the range with the name of the worksheet and an exclamation point; for example, Budget!A1:C7. Note When you export to a spreadsheet, you must leave this argument blank. If you enter a range, the export will fail.
Why not just import all columns and ignore the additional columns D and E imported into your table? You are not obliged to refer to them in whatever subsequent queries you use on your Excel-imported data if you do not need to.

-Stewart
Jan 12 '09 #3

Post your reply

Sign in to post your reply or Sign up for a free account.