Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #5  
Old 04-01-2020, 11:51 PM
Guessed's Avatar
Guessed Guessed is offline Different suffix per entry Windows 10 Different suffix per entry Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 4,185
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

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
Reply With Quote
 

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Title and Suffix in contacts narvan21 Outlook 0 12-22-2017 02:00 AM
Different suffix per entry 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

Other Forums: Access Forums

All times are GMT -7. The time now is 08:51 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft