Computing.Net > Forums > Database > Multiple Excel Worksheets to Access

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Multiple Excel Worksheets to Access

Reply to Message Icon

Name: elantro
Date: October 25, 2006 at 19:27:25 Pacific
OS: Windows 2003
CPU/Ram: Athlon 2500+ / 1GB PC3200
Comment:

I have a large number of sheets (120) in a single Excel workbook file. I can import each sheet individually into an Access table using the import wizard from Access. However, the task is very time consuming. I was wondering if there is a macro or code that can import all the worksheets from my workbook into individual tables in Access with a single command.

Your help is highly appreciated.

Thanks.



Sponsored Link
Ads by Google

Response Number 1
Name: pingy
Date: October 26, 2006 at 12:36:40 Pacific
Reply:

You could try it in Access VBA with something like:

Sub DoExcel()
Dim appExcel As Excel.Application
Dim wb As Excel.Workbook
Dim sh As Excel.Worksheet
Dim strValue As String
Dim intRow As Integer
Dim intCol As Integer
Dim rs As Recordset

Set rs = CurrentDb.OpenRecordset("YourTable")
Set appExcel = CreateObject("Excel.Application")
Set wb = appExcel.Workbooks.Open("blahblah.xls")
For Each sh In wb.Sheets
strValue = sh.Cells(intRow, intCol)
rs.AddNew
'Do your stuff
rs.Update
Next
rs.Close
wb.Close
appExcel.Quit
End Sub

Check http://www.dummies.com/WileyCDA/Dum... for adding the correct reference to the Excel object library.

Good luck

P.S. The VBA Code get's a little mixed up in this hml page.


0
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Database Forum Home


Sponsored links

Ads by Google


Results for: Multiple Excel Worksheets to Access

converting excel worksheets to access tables www.computing.net/answers/dbase/converting-excel-worksheets-to-access-tables/651.html

Convert Excel to Access database www.computing.net/answers/dbase/convert-excel-to-access-database/39.html

Import Excel to Access 2000 www.computing.net/answers/dbase/import-excel-to-access-2000/451.html