Import Spreadsheet

afs24

Board Regular
Joined
Sep 26, 2002
Messages
237
I'm trying to import this file from an excel file to an access database. I'm using the macro function but it's not working for some reason. This is how I wrote the location in the File Name section in the macro:

L:\QCKRESP\Vendor Operations\Summary Reserve On Hand Weekly OH

The L drive is mcssrv02. Would it be

mcssrv10:\QCKRESP\Vendor Operations\Summary Reserve On Hand
or
L:\QCKRESP\Vendor Operations\Summary Reserve On Hand
Weekly OH

Can I code this to make it easier? The table I'm importing it to is tbl_Pre. I need cells A1: F100 imported. Could you provide me with an example.
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
Another thought: You could create a named range for the cells that you want to import. Access will then know exactly what to grab.

Currently away from an Access machine, but will have a look for an example when I get back.
 
Upvote 0
As I mentioned in the previous post, using a named range is probably the best way to refer to your target cells.

The code to import the data is shown below:

Function ImportData()

DoCmd.TransferSpreadsheet acLink, 8, "MyRangeName", "Full path of file that contains the range.xls", True, "Destination Table"

End Function

I placed this inside a module called basImport. To call it you must make it a function -- then you can trigger the import from, say, a command button.

In the Click event of the command button type the statement

basImport.ImportData

That should do it.

Denis
 
Upvote 0

Forum statistics

Threads
1,221,552
Messages
6,160,462
Members
451,648
Latest member
SuziMacca

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
Back
Top