Exporting Data from table to CSV file

kmurtha

Board Regular
Joined
Mar 24, 2004
Messages
52
Hey All,

This is probably a simpel task but the process escapes me.

Using a macro, I want to take all the rows I have in a table and export them to a CSV file and then delete the rows in the table. What is the best way to do this?

Thanks much
(y)
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
Here is some simple code that will do that. Simple replace the Table Names and export file names to suit your needs:
Code:
Sub ExportMacro()

'   Export file to CSV file
    DoCmd.TransferText acExportDelim, "", "Table1", "C:\C\Test.csv", False, ""

'   Delete data from table
    CurrentDb.Execute "DELETE * FROM Table1"

End Sub
 
Upvote 0

Forum statistics

Threads
1,221,814
Messages
6,162,132
Members
451,743
Latest member
matt3388

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