logo
search
Data Import & Export

How to Automatically Update a CSV File from an Excel Workbook

Camila MilosovichCamila Milosovich Oct 8, 2026 869 views

Question details

The user wants to automatically update a saved CSV file whenever changes are made in the source Excel workbook.

How to Automatically Update a CSV File from an Excel Workbook
Product
Excel
Device & OS
not provided
Scenario
Exporting data to a CSV for external uses like a mail merge that requires up-to-date information from a dynamic source workbook.
Observed behavior
CSV files are plain text and do not retain formulas or external links, meaning they remain static and do not automatically update when the original Excel workbook changes.
Before you start

Ensure that your spreadsheet program has Developer tools enabled, as automatically exporting data to a CSV requires running a background VBA script.

Solution 1Recommended

Use a VBA Macro to Auto-Export CSV on Save

Use the Workbook_BeforeSave event to automatically generate and overwrite a specific CSV file every time you save your main Excel workbook.

Since CSV files are plain text, they cannot hold live formulas or maintain links to external workbooks. To keep a CSV updated with your latest calculations, you must actively re-export the data.

By using a short VBA script, you can automate this export process so that a fresh CSV is generated in the background whenever you save or close the master file.

1
Open the VBA Editor

Press ALT + F11 on your keyboard to open the Visual Basic for Applications (VBA) editor in your spreadsheet.

2
Access the Workbook Module

In the Project Explorer pane on the left, double-click on 'ThisWorkbook'.

3
Add the BeforeSave Event

Select 'Workbook' from the left dropdown menu and 'BeforeSave' from the right dropdown menu at the top of the code window.

4
Insert the Export Script

Write the VBA code to copy your target worksheet, save it as a CSV format to your specified folder path, and close the newly created CSV to prevent prompt interruptions.

5
Save as Macro-Enabled

Return to your spreadsheet, go to File > Save As, and choose 'Excel Macro-Enabled Workbook (*.xlsm)' so your automation code runs in future sessions.

Check Export Parameters: Verify that your VBA script uses the correct export path, encoding, and delimiters required by the database or application that will consume the CSV file.
Automate Data with WPS Office

Easily Automate CSV Exports and Data Merges in WPS Spreadsheet

WPS Office provides robust support for VBA macros and direct mail merge capabilities. Whether you need to script an automatic CSV export or link your spreadsheet directly to a WPS Writer document, you can accomplish it seamlessly.

  1. 1. Open Your Data File: Launch WPS Spreadsheet and open the master workbook containing your formulas and formatted data.
  2. 2. Enable Macros: Navigate to the 'Tools' tab and click on 'Macro' to open the fully featured VBA editor.
  3. 3. Insert Automation Script: Paste your BeforeSave script into the ThisWorkbook module to automate the generation of your CSV file.
  4. 4. Use Direct Mail Merge (Optional): Alternatively, open WPS Writer, go to the 'References' or 'Mailings' tab, and directly import your spreadsheet data as a live source.
Full compatibility with Microsoft Excel VBA macros and .xlsm filesSave and export directly to CSV without formatting lossIntegrated Mail Merge linking seamlessly between WPS Spreadsheet and WPS WriterFree, lightweight, and easy to navigate tabbed interface
QA img-9

Frequently Asked Questions

Why doesn't my CSV file update when the source Excel file changes?

A CSV (Comma Separated Values) file is a plain text file. It cannot store external data connections, live Excel formulas, or macros. It only captures a snapshot of the text values at the exact moment it was saved.

Can I link a CSV file to another Excel workbook?

You can import a CSV file into an Excel workbook using Power Query or the Data tab so that Excel refreshes the imported text when the CSV changes, but a CSV file itself cannot pull in data from an Excel workbook.

Is it possible to auto-export a CSV without writing VBA code?

No, spreadsheet software does not have a native toggle to automatically sync or continuously export a secondary CSV file upon saving. Without using a VBA macro like Workbook_BeforeSave, you must manually use File > Save As and select the CSV format each time your data updates.