Hi all
I've managed to cobble together some code (I'm new to this!) to create a CSV from a formulated tab in a spreadsheet. This new csv should be called the name of the tab plus today's date. It will then prompt the user as to where to save this csv.
It all works fine apart from 3 small things, which I'm sure are very simple if you know what you're doing...
1) My dates are coming out as mm/dd/yyyy rather than dd/mm/yyyy
2) I don't want to include columns V,W or X
3) In my formulated tab, I've used a lot of IFs which have returned "" but can't seem to work out how to not include these entirely blank rows in the output csv
Code below:
Function FormatShortdate()
Dim sh As Worksheet
Set sh = ThisWorkbook.Sheets(3)
sh.Range("M:M").NumberFormat = "dd/mm/yyyy"
End Function
Sub Export()
Dim MyPath As String
Dim MyFileName As String
MyFileName = "Abbas_Sage_Import_" & format(Date, "ddmmyyyy")
Sheets("Abbas-Sage Import").Copy
Set rng = Sheets("Abbas-Sage Import")
With Application.FileDialog(msoFileDialogFolderPicker)
.Title = "Select a Folder"
.AllowMultiSelect = False
.InitialFileName = "" '<~~ The start folder path for the file picker.
If .Show <> -1 Then GoTo NextCode
MyPath = .SelectedItems(1) & ""
End With
NextCode:
With ActiveWorkbook
.SaveAs Filename:=MyPath & MyFileName, FileFormat:=xlCSV, CreateBackup:=False
.Close False
End With
End Sub
I'd HUGELY appreciate some help with this!
Thank you
Sophie
I've managed to cobble together some code (I'm new to this!) to create a CSV from a formulated tab in a spreadsheet. This new csv should be called the name of the tab plus today's date. It will then prompt the user as to where to save this csv.
It all works fine apart from 3 small things, which I'm sure are very simple if you know what you're doing...
1) My dates are coming out as mm/dd/yyyy rather than dd/mm/yyyy
2) I don't want to include columns V,W or X
3) In my formulated tab, I've used a lot of IFs which have returned "" but can't seem to work out how to not include these entirely blank rows in the output csv
Code below:
Function FormatShortdate()
Dim sh As Worksheet
Set sh = ThisWorkbook.Sheets(3)
sh.Range("M:M").NumberFormat = "dd/mm/yyyy"
End Function
Sub Export()
Dim MyPath As String
Dim MyFileName As String
MyFileName = "Abbas_Sage_Import_" & format(Date, "ddmmyyyy")
Sheets("Abbas-Sage Import").Copy
Set rng = Sheets("Abbas-Sage Import")
With Application.FileDialog(msoFileDialogFolderPicker)
.Title = "Select a Folder"
.AllowMultiSelect = False
.InitialFileName = "" '<~~ The start folder path for the file picker.
If .Show <> -1 Then GoTo NextCode
MyPath = .SelectedItems(1) & ""
End With
NextCode:
With ActiveWorkbook
.SaveAs Filename:=MyPath & MyFileName, FileFormat:=xlCSV, CreateBackup:=False
.Close False
End With
End Sub
I'd HUGELY appreciate some help with this!
Thank you
Sophie