DimitriosNik
07-19-2018, 09:03 AM
Hi,
I'm trying to delete a file, running VBA code where:
based on a cell value, the program looks for a file with the same name and then deletes it.
Here it looks for INACTIVE files, moves 1 cell to the right and then deletes the appropriate files from a folder.
Help would be much appreciated. :)
22590
This is how far I've got:
Sub delete_INACTIVE_files()
Dim r As Range
Dim path As String
Dim file_name As String
Dim actsh As Worksheet
Set actsh = ActiveSheet
Application.ScreenUpdating = False
Set r = ActiveSheet.Cells(1, 1)
Do Until r = ""
If UCase(r.Value) Like "INACTIVE" Then
ActiveCell.Offset(0, 1).Select
'I don't know how to insert the file name in the kill function
Kill ("C:\Users\NikolouzosD\AppData\Local\Temp\vbakillfunction" & file_name)
End If
Set r = r.Offset(1, 0)
Loop
End If
End Sub
I'm trying to delete a file, running VBA code where:
based on a cell value, the program looks for a file with the same name and then deletes it.
Here it looks for INACTIVE files, moves 1 cell to the right and then deletes the appropriate files from a folder.
Help would be much appreciated. :)
22590
This is how far I've got:
Sub delete_INACTIVE_files()
Dim r As Range
Dim path As String
Dim file_name As String
Dim actsh As Worksheet
Set actsh = ActiveSheet
Application.ScreenUpdating = False
Set r = ActiveSheet.Cells(1, 1)
Do Until r = ""
If UCase(r.Value) Like "INACTIVE" Then
ActiveCell.Offset(0, 1).Select
'I don't know how to insert the file name in the kill function
Kill ("C:\Users\NikolouzosD\AppData\Local\Temp\vbakillfunction" & file_name)
End If
Set r = r.Offset(1, 0)
Loop
End If
End Sub