Forum Discussion
OwenRandy214
Mar 04, 2024Copper Contributor
Need an excel macro/script to populate static data fields in a csv worksheet
I have a csv excel worksheet that I have to produce daily from a data file, exported from a fuel recorder box. I recorded a micro/script in excel to produce this worksheet. When completed...
OwenRandy214
Copper Contributor
here is that part of my current macro
Rows("2:2").Select
Selection.Delete Shift:=xlUp
Range("E3").Select
ActiveWorkbook.Save
Range("H3").Select
ChDir "C:\Users\rsrig\Desktop\New Fuel Box\Ready to Edit"
ActiveWorkbook.SaveAs Filename:= _
"C:\Users\rsrig\Desktop\New Fuel Box\Ready to Edit\Todays_Fuel_File_To Edit.csv" _
, FileFormat:=xlCSV, CreateBackup:=False
End Sub
Rows("2:2").Select
Selection.Delete Shift:=xlUp
Range("E3").Select
ActiveWorkbook.Save
Range("H3").Select
ChDir "C:\Users\rsrig\Desktop\New Fuel Box\Ready to Edit"
ActiveWorkbook.SaveAs Filename:= _
"C:\Users\rsrig\Desktop\New Fuel Box\Ready to Edit\Todays_Fuel_File_To Edit.csv" _
, FileFormat:=xlCSV, CreateBackup:=False
End Sub
Steve_SumProductCom
Mar 07, 2024Iron Contributor
You can use Format(Now(), "yyyy-mm-dd"). Change the format code to suit your needs.
For example:
ActiveWorkbook.SaveAs Filename:= _
"C:\Users\rsrig\Desktop\New Fuel Box\Ready to Edit\Todays_Fuel_File_To Edit" & Format(Now(), "yyyy-mm-dd") & ".csv" _
, FileFormat:=xlCSV, CreateBackup:=False
For example:
ActiveWorkbook.SaveAs Filename:= _
"C:\Users\rsrig\Desktop\New Fuel Box\Ready to Edit\Todays_Fuel_File_To Edit" & Format(Now(), "yyyy-mm-dd") & ".csv" _
, FileFormat:=xlCSV, CreateBackup:=False
- OwenRandy214Mar 07, 2024Copper ContributorThat works great, thanks