transfer a named range from excel to access...help

djsmarties

Board Regular
Joined
Sep 10, 2002
Messages
95
Hi, I want to import a range in an excel worksheet into access.
In access i use the transferspreadsheet action to do this. With a range defined as i.e. a1:c3 it works fine, but when i use a range name it doesn't work and i get an error message "can't find object..."

here is the code i use:

DoCmd.TransferSpreadsheet acImport, 8, "product_detail", "p:/project/country_input_template.xls", True, "product_detail"

The range in excel are columns. the reason i use a range name is because i don't import every column, for example i would not want to import colums c, f, and i. "product_detail" is the name of the range.

What's wrong with the code? I can't get it to work, i tried a lot of different things, but i always get the same error message.
Maybe it works better if i try to export from excel instead of importing using access code?
Thanks for your help.
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple

DonkeyOte

MrExcel MVP
Joined
Sep 6, 2002
Messages
9,123
djsmarties - I take it that my earlier suggesiton wasn't up to scratch?
 

djsmarties

Board Regular
Joined
Sep 10, 2002
Messages
95
lasw10, i was actually afraid of hearing your suggestion, because thats exactly what i didn't want to do...studpid access. nobody else replied so i started another cry for help :) thanks anyway.
oh, i asked some other people, and you seem to be right, copy-pasting seems to be the only possibility...
 

DonkeyOte

MrExcel MVP
Joined
Sep 6, 2002
Messages
9,123
the only other thing is that of course you specify the range on the sheet...so in theory you could have one VERY large worksheet as opposed to numerous smaller ones...then copy each range into a different Access Table...

Guess it depends on the volume of data you have...
 

klb

Well-known Member
Joined
Apr 3, 2002
Messages
821
dj:

I tried your code substituting my own file path (and the correct characters instead of /) and it worked fine the second time.

The first time I tried it I received the same error as you did but then I realized that the file I was trying to import from was still open. When I closed the xls file, the code worked just fine.
 

Forum statistics

Threads
1,143,743
Messages
5,720,601
Members
422,292
Latest member
Bernd0501

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top