Pinaceous
Well-known Member
- Joined
- Jun 11, 2014
- Messages
- 1,113
- Office Version
- 365
- Platform
- Windows
Hi All!
I have a sub that Creates a Folder and sticks a document into it and places it onto my desktop! (Finally!)
I have a secondary code, which also works wonderfully and creates folders based upon cell designation in my workbook:
My question is, how can I combine these two codes in order to allow the newly created folders by the second code to be placed into the 1st code?
For example, how can I create a condition to allow the
to be placed into the folder created by the
??
Please let me know, if you have any suggestions!
Thanks,
~Pin
I have a sub that Creates a Folder and sticks a document into it and places it onto my desktop! (Finally!)
VBA Code:
Sub CreateFolders()
'(01) Documents
Dim FSO As Object, sourceFolder As Object, file As Object
Dim sPath As String, sMain As String, sFolder As String
Dim i As Long
Set FSO = CreateObject("Scripting.FileSystemObject")
sPath = CreateObject("WScript.Shell").SpecialFolders("Desktop")
sMain = sPath & "\" & ThisWorkbook.Sheets(1).Range("B11").Value
If Dir(sMain, vbDirectory) <> "" Then 'if the folder exists
'Do nothing
MsgBox "Duplicate Folders!"
'MsgBox Application.UserName & " Duplicate Folders!"
'MsgBox Environ("Temp") & " Hello!"
Exit Sub
Else ' 'if the folder not exists
MkDir sMain
FSO.copyFile Source:="F:\MISC\IMPORT.pdf", Destination:=sMain & "\IMPORT.pdf"
End If
End Sub
I have a secondary code, which also works wonderfully and creates folders based upon cell designation in my workbook:
VBA Code:
Sub MakesFolders()
Dim FldrName As String
On Error Resume Next
For i = 11 To 23
FldrName = Cells(i, 3).Value
MkDir "C:\Users\Desktop\" & FldrName
Next i
End Sub
My question is, how can I combine these two codes in order to allow the newly created folders by the second code to be placed into the 1st code?
For example, how can I create a condition to allow the
VBA Code:
Sub MakesFolders()
VBA Code:
Sub CreateFolders()
Please let me know, if you have any suggestions!
Thanks,
~Pin
Last edited: