This peice of code is just suppose to create the new month and year if the directory doesnt exist. At times when I test, it will create the path but then if I try to run again, it will not save if the month already exists. I took this piece of code from a posting but havent been able to get it to work smoothly. any ideas?
thanks so much!
thanks so much!
Code:
prmptyear = Format(x1, "YYYY")
prmptmonth = Format(x1, "MMM")
fpath = "S:\USA-HOUSTON\FAMM\jcb39tfm\Bunker Price Reporting" & "\" & prmptyear & "\" & prmptmonth '____
fname1 = "BunkerPR_" & Format(x1, "mmddyyyy")
fwrkbk1 = fname1 & ".xls"
filenme1 = fpath & "\" & fwrkbk1
If Len(Dir(fpath)) > 0 Then
ActiveWorkbook.SaveAs Filename:=filenme1
Else
MkDir Len(Dir(fpath))
End If
ActiveWorkbook.SaveAs Filename:=filenme1
Last edited: