Skip to content

Instantly share code, notes, and snippets.

@DataSolveProblems
Created October 28, 2019 04:36
Show Gist options
  • Save DataSolveProblems/93539e86bf52594f1b9e0e4f778aa6e7 to your computer and use it in GitHub Desktop.
Save DataSolveProblems/93539e86bf52594f1b9e0e4f778aa6e7 to your computer and use it in GitHub Desktop.
Option Explicit
Dim Status As String
Sub Main()
Dim LastRow As Long, iRow As Long
Dim FolderPath As String
Dim wsApp As Worksheet
Set wsApp = ThisWorkbook.Worksheets("App")
With wsApp
LastRow = .Cells(Rows.Count, "B").End(xlUp).Row
FolderPath = .Range("FolderPath").Value
If Dir(FolderPath, vbDirectory) = vbNullString Then
MsgBox "Invalid Base Folder Provided.", vbExclamation
Exit Sub
End If
If 6 > LastRow Then
MsgBox "No item provided.", vbExclamation
Exit Sub
End If
For iRow = 6 To LastRow
If .Cells(iRow, "B").Value <> "" Then
CreateFolder .Cells(iRow, "B").Value, FolderPath
.Cells(iRow, "C").Value = Status
End If
Next iRow
End With
MsgBox "All folder created successfully.", vbInformation
Set wsApp = Nothing
End Sub
Private Sub CreateFolder(ByVal SubFolder As String, ByVal BaseFolder As String)
Dim strTemp As String
Dim fso As Object
Set fso = CreateObject("Scripting.FileSystemObject")
Status = ""
strTemp = CleanFolderName(SubFolder)
If fso.FolderExists(BaseFolder & "\" & strTemp) Then
Status = "Folder Exists Already"
Else
If Len(strTemp) > 0 Then
MkDir BaseFolder & "\" & strTemp
Status = "Success"
End If
End If
Set fso = Nothing
End Sub
Public Function CleanFolderName(ByVal FolderName As String) As String
Dim i As Long
Dim strTemp As String
For i = 1 To Len(FolderName)
Select Case Mid(FolderName, i, 1)
Case "/", "\", ":", "?", "<", ">", "|"
strTemp = strTemp & "_"
Case Else
strTemp = strTemp & Mid(FolderName, i, 1)
End Select
Next i
CleanFolderName = strTemp
End Function
@choeng1
Copy link

choeng1 commented Jun 12, 2022

@choeng1
Copy link

choeng1 commented Jun 12, 2022

PyQt5 Login Form Simple.py

PyQt5 Login Form Simple.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment