Evening
I have a spreadsheet that saves data as a link on another spreadsheet but the problem is that each time I run the template all the previous links update to the new file name. is their a way to prevent this or am I missing something obvious? Thanks in advance the relevant bit of code shown below.
I have a spreadsheet that saves data as a link on another spreadsheet but the problem is that each time I run the template all the previous links update to the new file name. is their a way to prevent this or am I missing something obvious? Thanks in advance the relevant bit of code shown below.
VBA Code:
If wbook Is Nothing Then
Workbooks.Open FileName:=Environ("USERPROFILE") & "\Dropbox\SPSL Shared\Estimates 2021\JobList.xlsx" ' substitute for directory location of workbook and correct Filename
Workbooks("JobList.xlsx").Activate
Worksheets("JobList").Range("A" & Cells(Rows.Count, "A").End(xlUp).Row + 1).PasteSpecial Paste:=xlPasteValues
End If
Application.AskToUpdateLinks = False
Application.DisplayAlerts = False
ThisWorkbook.Activate
With Sheets("Markup")
ActiveSheet.Unprotect "sandym0unt"
wbNam = Range("B102")
dt = Format(CStr(Now), "dd_mm_yyyy")
ChDir Environ("USERPROFILE") & "\Dropbox\SPSL Shared\Estimates 2021\Instadoor Estimates" ' Directory wher you want file saved.
ActiveWorkbook.SaveAs FileName:=wbNam & " " & dt, FileFormat:=(52)
Worksheets("Markup").Range("C100:I100").Copy
Workbooks("JobList.xlsx").Activate
Worksheets("JobList").Range("A" & Cells(Rows.Count, "A").End(xlUp).Row).Offset(0, 3).PasteSpecial Paste:=xlPasteValues
ThisWorkbook.Activate
Worksheets("Markup").Range("B101:D101").Copy
Workbooks("JobList.xlsx").Activate
Worksheets("JobList").Range("A" & Cells(Rows.Count, "A").End(xlUp).Row).Offset(0, 11).Select
ActiveSheet.Paste Link:=True
Worksheets("JobList").Range("A" & Cells(Rows.Count, "A").End(xlUp).Row).Offset(0, 12).FormulaR1C1 = "=IF(RC[-1]="""","""",RC[-1]*1.2)"
dt = Format(CStr(Now), "dd mmmm yyyy")
Workbooks("JobList.xlsx").Activate
Worksheets("JobList").Range("A" & Cells(Rows.Count, "A").End(xlUp).Row).Offset(0, 14).Value = dt
Cells(1, 1).Select