Importing New Excel Sheet to Access

MattH1

Board Regular
Joined
Jul 15, 2016
Messages
174
Hey,

I'm currently working with a VBA code that filters data (as some of you may have seen from my last topic) and creates a new file from this filter. Once it saves the file, I was hoping there would be a way to save this as it's own Access Database. I am creating 15 different files and want to save each one as its own database so that it can be opened up as soon as the macro finishes.

Here's the location where I would like the code and the file name I would want (it'll be the same name as the Excel sheet it comes from.)
This is my VBA code to save as an excel document, what do I do from here to make it ALSO save as an access database?
Code:
'Save directory
Dim Filter1Directory As String
Filter1Directory = SaveDirectory & "Filter1" & Format(Date, "mmddyy") & ".xlsx"'Save the file
Application.DisplayAlerts = False
Filter1NewWB.SaveAs FileName:=FilterDirectory, FileFormat:=51
Application.DisplayAlerts = True

In this scenario, I have defined SaveDirectory previously in my VBA code. How can I add to this code to save it as an Access Database (or import and save it) after saving it as it's own Excel workbook? I would want this to happen for each workbook I create. I assume it's a simple code I've just never worked with importing/exporting in VBA before. Thank you!
 
Last edited:

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.

Forum statistics

Threads
1,191,696
Messages
5,988,162
Members
440,131
Latest member
EricMoz

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
Top