import 2 sheets from excel into two diff tables in access

dalerguy

Board Regular
Joined
Mar 2, 2005
Messages
51
Hi,

I've created a xls file containing 2 sheets named auth & recur. My objective is to get sheet auth & sheet recur imported to their respective tables in the database.

This will be a daily process. The filename looks like this 04-05-2005.xls.

I'm thinking the best way is to have the user specify the file name (location will remain static) then pass the variable to the macro.

I have two questions:

1. how do I reference each sheet and import the proper data to access

2. How can I prompt the user to specify the file name before running the import.

Any help will be appreciated

Thanks,

Mike
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
Mike

Try this.

Change the columns and path as required.
Code:
Sub Test()
Dim sDate

    sDate = InputBox("Please enter filename:", "Enter filename", Format(Date, "mm-dd-yyyy"))
    DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9, "auth", "C:\" & sDate & ".xls", True, "auth!A1:B65536"
    DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9, "recur", "C:\" & sDate & ".xls", True, "recur!A1:B65536"
    
End Sub
 
Upvote 0

Forum statistics

Threads
1,221,899
Messages
6,162,686
Members
451,782
Latest member
LizN

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