Hi i have the following VBA code to create folders - however, how can i edit this code so if i have two folders with the same name for eg
02052018
02052018
the code will make it do
02052018
02052018 - 2 ( or - 3...depending the number of times it has been copied over)
02052018
02052018
the code will make it do
02052018
02052018 - 2 ( or - 3...depending the number of times it has been copied over)
Code:
Sub MakeFolders()
Dim xdir As String
Dim FSO
Dim destfol As String
Dim lstrow As Long
Dim i As Long
destfol = Range("B3").Value
Set FSO = CreateObject("Scripting.FileSystemObject")
lstrow = Cells(Rows.Count, "f").End(xlUp).Row
Application.ScreenUpdating = False
For i = 8 To lstrow '<-- reads list from F2
'change the path on the next line where you want to create the folders
xdir = Range("B3").Value & Range("f" & i).Value
If Not FSO.FolderExists(xdir) Then
FSO.CreateFolder (xdir)
End If
Next
Application.ScreenUpdating = True
MsgBox i - 8 & " folders created in Directory :" & destfol
End Sub