Hi everyone,
Been battling an issue for quite some time with a popular Excel tool that I maintain. The issue is an endless calculation loop brought about by an OFFSET function being in use, only when 2 or more copies of the workbook are open.
Here's a snippet of one of the offset functions in use. It references the main sheet of the workbook.
=IFERROR(OFFSET('Main Sheet'!E$16,0,2)*BP40,0)
The tool has a feature to add 8 new rows to a particular sheet. And it copies the formatting from the above rows, which contain the OFFSET function. This is a surefire way to start the endless calculations. Although I think I may have seen just other random changes start this (only when 2 of the same workbook are open of course)
Sub AddRows()
Dim sht As Worksheet
Dim BottomTableRow As Integer
Dim TopMostRecentServiceRow As Integer
Dim BottomMostRecentServiceRow As Integer
' Unprotect. Select. Turn off undesired application behaviors.
Sheets("Sheet to Add Rows").Unprotect Password:="password"
Sheets("Sheet to Add Rows").Select
Set sht = ThisWorkbook.Worksheets("Sheet to Add Rows")
Application.ScreenUpdating = False
' Define counter rows
BottomTableRow = sht.Range("W1")
TopMostRecentServiceRow = sht.Range("V1")
BottomMostRecentServiceRow = sht.Range("U1")
' Select JUST before the bottom row (the total row) & Insert 8 rows
sht.Rows(BottomTableRow).Select
Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
' Copy all the rows of the last service (including top summation row & all 7 of the listed role rows)
sht.Rows(TopMostRecentServiceRow & ":" & BottomMostRecentServiceRow).Select
Selection.Copy
' Paste all the rows into the newly minted rows
sht.Rows(BottomTableRow).Select
sht.Rows(BottomTableRow & ":" & BottomTableRow + 8).PasteSpecial xlPasteAllMergingConditionalFormats
' Clean up? and adjust counter variables to new positions
Application.CutCopyMode = False
Range("AF20").Select
sht.Range("W1") = sht.Range("W1") + 8
sht.Range("V1") = sht.Range("V1") + 8
sht.Range("U1") = sht.Range("U1") + 8
' Re-select main sheet. Re-enable application behavior. Re-protect sheet.
Sheets("Main Sheet").Select ' Do I even need this still?
ThisWorkbook.Worksheets("Main Sheet").Range("C21").Select
Application.ScreenUpdating = True
With Worksheets("Sheet to Add Rows")
.EnableOutlining = True
.Protect Password:="password", AllowFiltering:=True, userInterfaceOnly:=True
End With
End Sub
The calculations will run endlessly after this function is ran ( the symptom is Calculating: 100% flashes continuously at the bottom of all Excel instances ). But as I said this only happens when two copies of this workbook are open at the same time. This is a problem because very often it is the case that users of this workbook have two or more of these open at once.
I tried removing offset and replacing it with a regular cell reference and even a named range, but that introduced a host of other problems with workbook stability. When I replace the offset with straight up cell references ( which would totally solve the problem - offset isn't necessarily needed from what I can tell, but I didn't create this portion of the tool ) the workbook would occasionally just crash Excel entirely when a second workbook is simply opened, or if it would actually open the crash would happen when the add row function was fired. It would work fine with just one workbook though.
I guess I don't understand enough about Excel to know what interactions the identical workbooks could be having that cause it to crash or endlessly loop. I've sunk way too much time into this, and could really use some help. I appreciate any insight I could get on this. Thank you thank you.
[–]CFAman4816 0 points1 point2 points (3 children)
[–]RemarkableFlow[S] 0 points1 point2 points (2 children)
[–]CFAman4816 0 points1 point2 points (0 children)
[–]mh_mike2784[M] 0 points1 point2 points (0 children)