How to Automatically Delete Cell Contents After One Year in Excel
Question details
The user wants to know if Excel can automatically delete cell contents containing data or records that are older than one year.

- Product
- Excel
- Device & OS
- not provided
- Scenario
- Managing large datasets and automatically purging outdated records to keep the spreadsheet clean.
- Observed behavior
- Excel formulas and conditional formatting can identify data older than one year, but they cannot automatically delete the cell contents on their own.
Before implementing any automated deletion scripts, ensure you create a backup copy of your workbook to prevent accidental permanent data loss.
Use a VBA Macro to Automate Deletion
Since native Excel formulas cannot delete data, using a VBA macro is the most effective way to automate the clearing of cell contents older than 365 days.
VBA (Visual Basic for Applications) allows you to write a script that iterates through a specific date column in your spreadsheet, calculates the age of the record, and clears the contents if it exceeds one year. This method requires saving your file as a Macro-Enabled Workbook (.xlsm).
Press Alt + F11 on your keyboard to open the Microsoft Visual Basic for Applications editor.
Click on 'Insert' in the top menu and select 'Module' to create a blank script window.
Enter a VBA loop that compares the date in your target cells against 'Date - 365'. If the condition is met, use 'Selection.ClearContents' or specify the cell range to clear the data.
Save your workbook, close the editor, and run the macro from the 'Developer' tab by clicking 'Macros', selecting your new script, and clicking 'Run'.

Highlight Old Data for Manual Deletion
If you prefer not to use macros, you can use conditional formatting to highlight data older than one year for quick, safe manual deletion.
Automate Data Deletion with WPS Spreadsheet
WPS Spreadsheet provides robust support for VBA macros and advanced conditional formatting, allowing you to easily identify and clear old records exactly as you would in Microsoft Excel.
- 1. Open Your Data File: Launch WPS Spreadsheet and open the workbook containing your dated records.
- 2. Access the Macro Editor: Navigate to the 'Tools' tab on the ribbon and click on 'Macro' to open the VBA editor.
- 3. Run Your Cleanup Script: Insert your VBA code to locate cells older than 365 days and clear their contents, then execute the script to instantly clean your dataset.

Frequently Asked Questions
Can an Excel formula directly delete cell contents?
No, Excel formulas are designed strictly to perform calculations and return values to the cell they reside in. They cannot change, format, or delete the contents of other cells.
How can I automatically clear cells without using VBA?
You can use Power Automate to create a scheduled cloud workflow. By connecting it to an Excel Online table, you can set the flow to check for dates older than one year and update those specific rows by clearing out the target fields.
Is there a way to hide old data instead of permanently deleting it?
Yes. Instead of deleting, you can select your data header, go to the 'Data' tab, and click 'Filter'. Under the date column filter options, select 'Date Filters', then 'Before...', and choose a date from exactly one year ago. This will hide older entries while keeping the data safely in your file.




