I am attempting to merge 2 macros but seem to be missing something
1 the first macro I have uses cell value to create folder and file (works fine)
2 the second macro copy's a worksheet and saves it to default folder as a .csv (works fine)
I am attempting to merge the 2 codes so that when executed macro will create folder
and copy and save worksheet in created folder as a .csv
1 the first macro I have uses cell value to create folder and file (works fine)
2 the second macro copy's a worksheet and saves it to default folder as a .csv (works fine)
I am attempting to merge the 2 codes so that when executed macro will create folder
and copy and save worksheet in created folder as a .csv
VBA Code:
Sub tstcsv()
Dim strFilename, strDirname, strPathname, strDefpath As String
On Error Resume Next
Worksheets("Dashboard").Select
strDirname = Range("A4").Value
strFilename = Range("B4").Value
strDefpath = "C:\MidSouth\PENDING\"
If IsEmpty(strDirname) Then Exit Sub
If IsEmpty(strFilename) Then Exit Sub
Worksheets("Google").Copy
If Not Right(Defpath, 1) = "\" Then Defpath = Defpath & "\"
If Not Right(strFilename, 4) = ".csv" Then strFilename = strFilename & ".csv"
Application.DisplayAlerts = False
With ActiveWorkbook
MkDir strDefpath & strDirname
strPathname = strDefpath & strDirname & "\" & strFilename 'create total string
ActiveSheet.ExportAsFixedFormat Type:=xlCSV, filename:= _
strDefpath & strDirname & "\" & strFilename, Quality:=xlQualityStandard, _
IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=False
.Close True
End With
Application.DisplayAlerts = True
End Sub