VBA code to rename and save file doesn't always save the files with formulas.

MFK85

New Member
Joined
Nov 27, 2015
Messages
11
Hello i have the following code:
Sub XX()
Dim Path1 As String
Dim filename As String
Dim MyOldName As String
Dim thisWb As Workbook
Dim CO As String
Dim newname As String
filename = ("XX")
Set thisWb = ActiveWorkbook
myfirstname = Left(ActiveWorkbook.Name, InStr(ActiveWorkbook.Name, ".") - 1) 'ActiveWorkbook.Name & xlTypePDF '".pdf" '"ZNA " & Filename2 & " " & Filename & ".xls"
MyOldName = ActiveWorkbook.FULLNAME

Application.DisplayAlerts = False

CO = Range("K7").Value


If CO = "JX" Then
Path1 = "C:\Users\Public\Dropbox (JX Purchasing)\NEW PEND OR NOCAL\PO TO CONFIRM\TODAYS TO SEND\"
End If
If CO = "JFC" Then
Path1 = "C:\Users\Public\Dropbox (JX Purchasing)\NEW PEND OR SOCAL\PO TO CONFIRM\TODAYS TO SEND\"
End If



ActiveWorkbook.SaveAs filename:=Path1 & filename & " " & myfirstname, FileFormat:=xlNormal
Kill MyOldName


ActiveWorkbook.Close SaveChanges:=True

End Sub


The code basically renames the file, saves the file to a diff location, deletes the old file.
The code works fine it seems - except for occasionally the files that are saved (they have a bunch of vlookup formulas in them linking to external files.) instead of saving the formulas , the vlookup value is saved in a cells but the formulas are no longer there - instead it has a =#VALUE! in the formula bar when i click on the cells... All the external links are gone as well.. I have never encountered this issue before, any help would be greatly appreciated. Using Office 365.
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.

Forum statistics

Threads
1,215,066
Messages
6,122,947
Members
449,095
Latest member
nmaske

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top