![]() |
|
#5
|
||||
|
||||
|
The following is an example to create the folder structure you described with 5 digit padding and only taking inputs from the part numbers you select before running it. Note that you need to set a Reference to the Microsoft Scripting Runtime.
Code:
Sub MakeFolders()
'requires reference to Microsoft Scripting Runtime
Dim subFolders() As String, sPath As String, aCell As Range
Dim iNum As Long, sCell As String, sFolder As String, i As Integer
Dim sPathF As String, sPathSubF As String
Dim fso As New FileSystemObject
sPath = "C:\Temp\"
subFolders = Split("Calculations|Capacities|Correspondence|Inspections", "|")
For Each aCell In Selection
sCell = Trim(aCell.Value)
iNum = Mid(sCell, 3)
sFolder = "PN" & Format(iNum, "00000")
sPathF = sPath & sFolder
If Not fso.FolderExists(sPathF) Then fso.CreateFolder sPathF
For i = LBound(subFolders) To UBound(subFolders)
sPathSubF = sPathF & "\" & sFolder & " - " & subFolders(i)
If Not fso.FolderExists(sPathSubF) Then fso.CreateFolder sPathSubF
Next i
Next aCell
End Sub
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Title and Suffix in contacts | narvan21 | Outlook | 0 | 12-22-2017 02:00 AM |
Batch add suffix to PDF files in folder
|
Dave T | Windows | 2 | 03-01-2016 08:07 PM |
| Macro to rename multiple Word file with same suffix | ozil61 | Word VBA | 2 | 05-06-2014 07:36 AM |
| Outlook Restriction? php link suffix | MWE | Outlook | 0 | 11-17-2010 07:25 PM |
| Name suffix in Reference Manager | bellczar | Word | 0 | 03-08-2010 03:14 PM |