Hi all,
The below code works great, but I was wondering how to tweak it slightly - I have the path set, but was looking to see if I could set a dropdown for months, and have it set the path as what it currently is, but point to a folder within there corresponding to the month?
eg path is "D:\Carcharias Creative\CSVs", I'd like to select a dropdown when naming the file for months, and have it save in "D:\Carcharias Creative\CSVs\August" for example
The below code works great, but I was wondering how to tweak it slightly - I have the path set, but was looking to see if I could set a dropdown for months, and have it set the path as what it currently is, but point to a folder within there corresponding to the month?
eg path is "D:\Carcharias Creative\CSVs", I'd like to select a dropdown when naming the file for months, and have it save in "D:\Carcharias Creative\CSVs\August" for example
VBA Code:
Sub ExportAsCSV()
Dim MyFileName As String
Dim Item As String
Dim Path As String
Dim CurrentWB As Workbook, TempWB As Workbook
Dim myrangeNA As Range
Dim myRangeCSV As Range
Path = "D:\Carcharias Creative\CSVs"
Set CurrentWB = ActiveWorkbook
ActiveWorkbook.Worksheets("CSV").Activate
Set myrangeNA = Application.InputBox(prompt:="Select a range to copy (include header row).", Type:=8)
Item = InputBox("Please input filename", "Filename")
Set TempWB = Application.Workbooks.Add(1)
myrangeNA.Copy Destination:=TempWB.Worksheets("Sheet1").Range("A1")
MyFileName = Path & "\" & Item & ".csv"
Application.DisplayAlerts = True
TempWB.SaveAs Filename:=MyFileName, FileFormat:=xlCSVUTF8, CreateBackup:=False, Local:=True
TempWB.Close SaveChanges:=False
Application.DisplayAlerts = True
End Sub