dwhitey1124
New Member
- Joined
- Oct 24, 2014
- Messages
- 28
Hi, I am using the below code in a large macro. I can't get it to work exactly. I am trying to have the old version of the file (which is the file being opened) moved from the current filepath to an archive folder. I would then save a new version of the folder in the current filepath. The closest I got to was saving the old version in the archive folder but was unable to delete the older version from the current filepath or save a new version to the current filepath. Ideally, VBA would cut the old file and paste it into the archive folder. And then save a new version of the file in the current filepath.
Any help would be much appreciated.
Thanks.
Any help would be much appreciated.
Thanks.
HTML:
Dim FName As String
Dim FPath As String
FPath = Sheet1.Range("C2").text
FName = Sheet1.Range("BQ1").text
ThisWorkbook.SaveAs Filename:=FPath & "\" & FName
Sheet1.Range("BQ1:BQ10").Calculate
Sheet1.Range("o1:V1").Calculate
'You can use this to delete one xls file in the folder Test
Sheet1.Range("BQ1").Copy
Sheet1.Range("BQ10").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
On Error Resume Next
Dim FName2 As String
Dim FPath2 As String
FPath2 = ThisWorkbook.Path
FName2 = Sheet1.Range("BQ10").text
Kill FPath2 & "\" & FName2
On Error GoTo 0
Dim FName3 As String
Dim FPath3 As String
FPath3 = ThisWorkbook.Path
FName3 = Sheet1.Range("BQ1").text
ThisWorkbook.SaveAs Filename:=FPath3 & "\" & FName3