hrq
12-07-2022, 04:42 AM
Hi All, how can the code be amend below so that subfolderpath folder will be created? Currently, if folderpath exist but subfolderpath does not exist, it kind of jump straight to End If.
I tried to include an ElseIf, it still doesn't work.
The code as follows:
If Dir(folderpath, vbDirectory) = "" And Dir(subfolderpath, vbDirectory) = "" Then
'check whether folder exist
MkDir folderpath
'create folder
MkDir subfolderpath
'create folder
If Dir(subfolderpath, vbDirectory) = "" Then
MkDir subfolderpath
'create folder
counter = counter + 1
End If
End If
If Dir(folderpath, vbDirectory) = "" And Dir(subfolderpath, vbDirectory) = "" Then
'check whether folder exist
MkDir folderpath
'create folder
MkDir subfolderpath
'create folder
ElseIf Dir(subfolderpath, vbDirectory) = "" Then
MkDir subfolderpath
'create folder
counter = counter + 1
End If
I tried to include an ElseIf, it still doesn't work.
The code as follows:
If Dir(folderpath, vbDirectory) = "" And Dir(subfolderpath, vbDirectory) = "" Then
'check whether folder exist
MkDir folderpath
'create folder
MkDir subfolderpath
'create folder
If Dir(subfolderpath, vbDirectory) = "" Then
MkDir subfolderpath
'create folder
counter = counter + 1
End If
End If
If Dir(folderpath, vbDirectory) = "" And Dir(subfolderpath, vbDirectory) = "" Then
'check whether folder exist
MkDir folderpath
'create folder
MkDir subfolderpath
'create folder
ElseIf Dir(subfolderpath, vbDirectory) = "" Then
MkDir subfolderpath
'create folder
counter = counter + 1
End If