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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBA code that will import an excel file and also include a tab name 2

Status
Not open for further replies.

maupiti

Programmer
Oct 27, 2003
240
US
Access 2003.

What is the VBA code that will not only import an excel file but also allows you to include a tab name and a range within that tab ?

/////////////////////////////////////////////////

No TAB name and no range specified

DoCmd.TransferSpreadsheet acImport, 8, "Table_Source_1", "C:\TEMP\Test.XLS", True, ""

/////////////////////////////////////////////////

Range specified, but there is no TAB name

DoCmd.TransferSpreadsheet acImport, 8, "Table_Source_1", "C:\TEMP\Test.XLS", True, "M1:M2"

/////////////////////////////////////////////////

What is an import code that is the same as above but, with
TAB (Customer) name specified as well as a range (M1:M2)within that TAB name.

 
This may help:
Importing Excel 97 Files Into Access Using VB Code
faq181-29
 
Hi!

I've not tried this in Access, but it works in Excel:

DoCmd.TransferSpreadsheet acImport, 8, "Table_Source_1", "C:\TEMP\Test.XLS", True, "SheetName!M1:M2"

If the sheet name has a space in it then you need to enclose it in single quotes.

hth


Jeff Bridgham
Purdue University
Graduate School
Data Analyst
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top