I have multiple folders(level 1) with folders (level 2) in them. I want to delete the level 2 folders (but not all of them).
so I want to go in to folder 1 and delete folders a-g (but not h-z), then move to folder 2 and repeat the same thing.
I have the list of the folder1's in column a of a document and a1 is the active cell.
below is the code I wrote for it.
the trouble I am having is the second do-while loop. it will change the rptday but is not deleting the files.
prior to adding the going through the folders the deleting do-while loop worked. and the first do-while loop appears to be working.
any suggestions
so I want to go in to folder 1 and delete folders a-g (but not h-z), then move to folder 2 and repeat the same thing.
I have the list of the folder1's in column a of a document and a1 is the active cell.
below is the code I wrote for it.
HTML:
Dim fso As Object
Dim fullfilelocation As String
Dim rptmonth As String
Dim rptday As Integer
Dim rptyear As String
Dim foldername As String
Dim filelocation As String
rptmonth = "06"
rptday = 1
rptyear = "11"
Set fso = CreateObject("Scripting.FileSystemObject")
foldername = ActiveCell.Value
Do Until IsEmpty(ActiveCell.Offset(1, 0))
foldername = ActiveCell.Value
fullfilelocation = "C:\Users\smakatura\Documents\call report\prep documents\test\" & foldername & "\" & rptmonth & "-" & rptday & "-" & rptyear
ActiveCell.Offset(1, 0).Select
MsgBox (fullfilelocation)
Do Until rptday = 32
If rptday < 10 Then
fullfilelocation = "C:\Users\smakatura\Documents\call report\prep documents\test\" & foldername & "\" & rptmonth & "-0" & rptday & "-" & rptyear
Else: fullfilelocation = "C:\Users\smakatura\Documents\call report\prep documents\test\" & foldername & "\" & rptmonth & "-" & rptday & "-" & rptyear
End If
If fso.FolderExists(fullfilelocation) Then
fso.DeleteFolder (fullfilelocation)
End If
rptday = rptday + 1
Loop
rptday = 1
Loop
Set fso = Nothing
the trouble I am having is the second do-while loop. it will change the rptday but is not deleting the files.
prior to adding the going through the folders the deleting do-while loop worked. and the first do-while loop appears to be working.
any suggestions