Hi
I have a couple of csv files that I open, copy sepcific data and paste into an excel file. What I then need to do is save the csv files into another folder.
I have the code below but it just saves both csv files as the same name so when it saves the second one it advises that it already exists???
Any ideas will be most apreciated
Formula:
Dim i As Integer
Dim NewFileName As String
Dim folderPath As String
Dim filename As String
Dim wb As Workbook
folderPath = "C:\Documents and Settings\HartG\My Documents\Projects\Cash errors reports\Imports\"
strPath = "C:\Documents and Settings\HartG\My Documents\Projects\Cash errors reports\Archive\"
strFileName = Format(Now(), "yyyy-mm-dd") & "_" & ActiveWorkbook.Name & "CSV"
If Right(folderPath, 1) <> "\" Then folderPath = folderPath + "\"
filename = Dir(folderPath & "*.CSV")
Do While filename <> ""
Application.ScreenUpdating = False
Set wb = Workbooks.Open(folderPath & filename)
Call Get_Data
wb.SaveAs filename:= strPath & strFileName, FileFormat:=xlCSV
wb.Close SaveChanges:=False
'Application.DisplayAlerts = False
filename = Dir
Loop
Application.ScreenUpdating = True
End Sub
Bookmarks