Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

TransferSpreadsheet command 1

Status
Not open for further replies.

m1kee

Programmer
Mar 2, 2003
45
GB
Hi folks,

Using the TransferSpreadsheet command in vba I know that you can import single sheets or named ranges, but.. I am importing details from one spreadsheet, but there are 3 different worksheets in it and each one goes into a different table. Is it possible to tell the system which of the worksheets I require. One way round this is to save them as 3 different spreadsheets but this is a bit of a waste if I can get around it the right way.

Many thanks in advance,
Mikee.

Do or do not, there is no try. - Yoda
 
Take a look at the 6th parameter (Range:=) of the DoCmd.TransferSpreadsheet method

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Hi PHV,

Checked the Range parameter, but when I put in the name of the sheet I get a runtime error telling me that the database cannot find, on this occasion "F1 Range".. ?

I put the name of the sheet in " " and that didn't help, is just naming the sheet normally sufficient?

Mikee.

Do or do not, there is no try. - Yoda
 
Try to use named range defined in excel
or something like Range:="Sheet2!A1:X100"

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
PHV

Top stuff - that does the trick, not they way I was thinking of, but all the same - it works :)

Cheers, Mikee.

Do or do not, there is no try. - Yoda
 
Just as an afterthought

If you import manually from the database window you can select sheets, shame that you can't do the same from vba, perhaps something for the developer at MS to think about.... maybe.


Do or do not, there is no try. - Yoda
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top