jondavis1987
Active Member
- Joined
- Dec 31, 2015
- Messages
- 443
- Office Version
- 2019
- Platform
- Windows
Below I have a vba to say a worksheet in a certain folder that changes. The folder is jname in the vba. How do i make it where it will create a folder with the name that jname. For instance the value in A!B4 could be 23727 and if a folder that is named 23727 doesn't exist it would create one at the proper location.
VBA Code:
Sub Export_Cores_as_PDF()
Dim FolderPath As String
Dim fName As String
Dim jName As String
fName = Sheets("A").Range("A!G8").Value
jName = Sheets("A").Range("A!B4").Value
FolderPath = "C:\Users\" & Environ("username") & "\Dropbox\Quality Control\Jobs\" & jName & "\"
Sheets(Array("Core Report", "Joints")).Select
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=FolderPath & fName, _
openafterpublish:=False, ignoreprintareas:=False
MsgBox "All PDF's have been successfully exported."
End Sub