Home Excel Powerpoint Word Outlook Error Codes

VBA Useful Codes

Welcome to the World of VBA
Home > VBAUsefulCodes

Delete File if Exists using VBA Excel

This is the code for deleting a specific file if it is exist using vba.

Sub Delete_file_if_exists()
Dim aFile As String
del_File = "C:\Users\welcome\Desktop\file_to_delete.txt"
If Len(Dir$(del_File)) > 0 Then
' File Exists, Delete it
Kill del_File
End If
End Sub


Enter your e-mail below and get notified on the latest blog posts.


VBA Outlook KPI Excel Alt+F11 Dashboards Macros Recording Graphs Automation Developer WaterFall Powerpoint Charts Pivot Tables Forecast Charts

Follow Us