Repository navigation
Move absolute references when inserting or removing rows and columns - #421
Merged
MathNya merged 1 commit intoNov 27, 2026
Merged
Conversation
shift_coordinate left the locked ($) column and row of a reference where they were, so after insert_new_row or remove_row, =SUM($H$1:$H$2), VLOOKUP(x,$A$2:$B$100,...) and =$H$4 read the wrong cells. In Excel $ only fixes a reference when a formula is copied or filled; inserting or removing cells moves it like any other. The copy path (shared formulas) uses adjustment_formula_coordinate and still keeps $ references. shared_adjustment_preserves_quoted_sheet inserts a row above E38, so its expected reference is now $E$39; the test is about the quoted sheet name.
Owner
|
@jayhemnani9910 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Inserting or removing rows and columns never moves absolute (
$) references in formulas, so they read the wrong cells afterwards:In Excel and LibreOffice
$only fixes a reference when a formula is copied or filled; inserting or deleting cells moves every reference to the moved cells.shift_coordinate(used only byadjustment_insert_formula_coordinateandadjustment_remove_formula_coordinate) skipped the locked part. It now shifts both parts and keeps the$. The copy path for shared formulas goes throughadjustment_formula_coordinateand still leaves$references alone. On the same insert, thePrint_Areadefined name already moved from$A$1:$F$5to$A$3:$F$7; formulas now match it.#410 kept the old behaviour for locked parts ("Locked (
$) parts are still left alone, as before"); this changes that.shared_adjustment_preserves_quoted_sheetinserts a row above'(1)'!$E$38, so its expected reference becomes$E$39; the test is about keeping the quotes on the sheet name.Tested: new
insert_and_remove_move_absolute_refsfails without the change;cargo testpasses. Reading an xlsx,insert_new_row(1, 2)and writing it back givesSUM($H$3:$H$4)andSUM(H3:H4). Not changed here: a range that starts on a removed row moves up a row ($G$2:$H$5after removing row 2 becomes$G$1:$H$4), which is how relative references are already handled.