I found this VBA code that works great for my needs, however there is one little problem. If there is a Blank in column A, meaning no more folder names, then the VBA code lists the status as "Folder already available". I would like to have an IF Statement added based on whether or not column A in that row is blank.
For instance, in my screenshot, there are new folder names for cells A4-A6, and the status of "Folder Created" is correct. However in rows 7-12, column A does not contain a value, so, column B in the corresponding row should reflect a blank cell also. Below is my code.
<code>
Option Explicit
Sub Create_Multiple_Folder()
Dim sh As Worksheet
Set sh = ThisWorkbook.Sheets("Sheet1")
Dim sub_folder_path As String
Dim i As Integer
For i = 4 To sh.Range("A" & Application.Rows.Count).End(xlUp).Row
sub_folder_path = sh.Range("C1").Value & Application.PathSeparator & sh.Range("A" & i).Value
If Dir(sub_folder_path, vbDirectory) = "" Then
MkDir (sub_folder_path)
sh.Range("B" & i).Value = "Folder Created"
Else
sh.Range("B" & i).Value = "Folder already available"
End If
Next i
End Sub
</code>
I don't really know why you have a table with blank rows in it, but you can use:
For i = 4 To sh.Range("A" & Application.Rows.Count).End(xlUp).Row If Len(sh.Cells(i, "A").Value) = 0 Then sh.Cells(i, "B").Value = vbNullString Else sub_folder_path = sh.Range("C1").Value & Application.PathSeparator & sh.Range("A" & i).Value If Dir(sub_folder_path, vbDirectory) = "" Then MkDir (sub_folder_path) sh.Range("B" & i).Value = "Folder Created" Else sh.Range("B" & i).Value = "Folder already available" End If End If Next i