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

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.

Forum statistics

Threads
1,214,641
Messages
6,120,684
Members
448,977
Latest member
dbonilla0331

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