Disable automatic updating of references in Excel using VBA

I am writing some macros in VBA for an Excel document, that uses a data base stored in 2 Worksheets, named “Datenbank” and “Stapler”. Here is some data stored. This 2 Worksheets are additionally stored in another Workbook stored in a server. There is a Worksheet in the Excel document, that calculate things using references from this 2 Worksheets used as the database. This calculations are of the type: = IF( F5 <> “”; XLOOKUP(F5; Stapler!B:B; Stapler!F:F; “”; 0); “”) or = IF( X5 <> “”; X5 * XLOOKUP(H5; Datenbank!F:F; Datenbank!H:H; 0; 0) / 1000; 0). The data base should be updatable from the server and you can just replace the existing worksheets “Datenbank” and “Stapler” with the new ones. The problem is, the references in the cells turn to “!REF#” (Error referencing) the moment you delete the old worksheets to replace them with the new updated ones, although the new ones have the exact same name and the old ones do not exist anymore. I assume this happens because Excel references the objects and not just their names, but if I could turn off this automatic update of references or do something to change the existing references to the new worksheets, it would be awesome. I have tried to change all formulas with Replace in Formula for all “UsedRange”, but that takes too long and also it doesn’t change the references made in some list dropdowns from data validation that also takes values from these 2 problematic worksheets.

Sub ImportDatenbankFunc()

' This Macro is responsible for the import of the Datenbank

    Dim Opfer1 As String, Opfer2 As String, Path As String, DatenbankPath As String, Version As String
    Dim Datenbank As Workbook, Rechner As Workbook
    
    Application.ScreenUpdating = False
    Application.Calculation = xlCalculationManual
    Application.EnableEvents = False
    Opfer1 = "Datenbank"
    Opfer2 = "Stapler"
    
    ' Delete the existing worksheets where Data is stored
    Application.DisplayAlerts = False
    ThisWorkbook.Worksheets(Opfer1).Delete
    ThisWorkbook.Worksheets(Opfer2).Delete
    Application.DisplayAlerts = True
    
    ' Path of server where the new/updated version of the Data is stored
    Path = Dir("/Volumes/Topix-AFP/0 - Dateianhänge/Förderrechner/")
    Set Rechner = ActiveWorkbook
    
    Do While Path <> ""
    ' While the Path isnt empty (while there is still documents in the folder)
        If Left(Path, 9) = "Datenbank" Then
            ' If the first 9 letters of the document are "Datenbank", then open it
            DatenbankPath = "/Volumes/Topix-AFP/0 - Dateianhänge/Förderrechner/" & Path
            Set Datenbank = Workbooks.Open(DatenbankPath)
            Exit Do
        
        End If
        
        Path = Dir()
        
    Loop
    
    ' Copy the Worksheets"Datenbank" and "Stapler"
    Datenbank.Worksheets("Datenbank").Copy After:=Rechner.Sheets(Rechner.Sheets.count)
    Datenbank.Worksheets("Stapler").Copy After:=Rechner.Sheets(Rechner.Sheets.count)
    ' At this point, because there was no longer an existing "Datenbank" or "Stapler" Worksheets
    '  the new ones do not have the "(2)" after the name
    ' Read the version of the datenbank and write it down in a cell of "Versionierung"
    Version = Datenbank.Name
    Version = Right(Version, Len(Version) - 11)
    Version = Left(Version, Len(Version) - 5)
    Rechner.Worksheets("Versionierung").Range("I5").Value = Version
    Datenbank.Close savechanges:=False
    Application.Calculation = xlCalculationAutomatic
    Application.EnableEvents = True
    Application.ScreenUpdating = True

End Sub

' Attempt to dereference all cells, takes too long and doesnt dereference Data validation lists

Sub DeReference()

    Const RechnerWS As String = "Rechner (2)"
    Const OldRefStap As String = "Stapler"
    Const NewRefStap As String = "'Stapler (2)'"
    Const OldRefDB As String = "Datenbank"
    Const NewRefDB As String = "'Datenbank (2)'"

    Dim Zelle As Range
    For Each Zelle In ThisWorkbook.Worksheets(RechnerWS).UsedRange.Cells
    
        Zelle.Formula = Replace(Zelle.Formula, OldRefStap, NewRefStap)
        Zelle.Formula = Replace(Zelle.Formula, OldRefDB, NewRefDB)
        
    Next Zelle

End Sub

I have also looked for a similar approach using Replace for the formula of the Dropdown list, but haven´t found anything. In a worst-case scenario, this would also be helpful.

New contributor

AndresC is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật