ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Save over files. (https://www.excelbanter.com/excel-programming/364559-save-over-files.html)

THE_RAMONES

Save over files.
 
I'm using the code below to pull multiple sheets together then move the files
to old folder. Say I want to run the sames files I ran through the macro
eariler it won't work if its already located in the old file folder.

Please let me know if you need more info to answer this question. Thanks


Application.EnableEvents = False
Application.ScreenUpdating = False
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
PathOld =
"R:\Reports\PDP-Reporting\CUSTOMER_SERVICE\DAILY\Scorecard\DATA_FE ED\CURRENT_STREAM_WellCare_PDP\OLD FILES\" 'Change as needed
Path =
"R:\Reports\PDP-Reporting\CUSTOMER_SERVICE\DAILY\Scorecard\DATA_FE ED\CURRENT_STREAM_WellCare_PDP" ''Change as needed
FileName = Dir(Path & "\WellcarePDP_Interval*.csv", vbNormal)
Do Until FileName = ""
Set Wkb = Workbooks.Open(FileName:=Path & "\" & FileName)
For Each WS In Wkb.Worksheets
If Left(WS.Name, 20) = "WellcarePDP_Interval" Then
WS.Copy After:=ThisWorkbook.Sheets(ThisWorkbook.Sheets.Cou nt)
End If
Next WS
Wkb.Close False
fso.MoveFile Path & "\" & FileName, PathOld
FileName = Dir()
Loop
Application.EnableEvents = True
Application.ScreenUpdating = True


All times are GMT +1. The time now is 09:01 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com