Avatar of bejhan
bejhan asked on

Using Range in DoCmd.TransferSpreadsheet acImport

I tried to use "A:P,T:U,W:X" as my range in DoCmd.TransferSpreadsheet acImport but I got the error:

DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9, "ntblNewItems", GetInputDirectory("New Business") & lstFileList, True, "A:P,T:U,W:X"

Runtime error 3011
The Microsoft Jet Database engine could not find the object 'A:P,T:U,W:X'

Is there a way to just import certain columns from a spreadsheet?
Microsoft AccessMicrosoft ExcelVisual Basic Classic

Avatar of undefined
Last Comment
Patrick Matthews

8/22/2022 - Mon


For multiple columns, you might want to make them into a named range, and then refer to the range by name when you using TransferSpreadsheet.


For more details, type Alt+F11, and in Help type - transferspreadsheet

The only problem with a named range is that the sheet is produced by a query someone pulls from a web app, so the named range would have to be added to the sheet by the user everytime wouldn't it?
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.

Umm... named ranges tend to be fairly dynamic, e.g. when you insert new rows, the range will expand automatically. But as far as external data sources are concerned, I'm not too sure. Are you using the external data source feature of Excel? Or using some code to pull the data in?
Patrick Matthews

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Log in to continue reading
Log In
Sign up - Free for 7 days
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.