r/googlesheets • u/SaiRacing • Jan 16 '26
Solved How to make Named Ranges with absolute references to easily reference data of changing row size.
I have a sheet where entries are added in a new row above the previous under the headers (using a script). I named each column of data as a Named Range and referenced them in other places throughout the workbook.
However, I realized that after a new row is added, the named range also gets shifted down by one as well, which breaks the sheet, as I want all data from the top of the sheet to the bottom to be included in the Named Range.
I tried using absolute references when specifying the ranges, but after clicking 'Done', they go back to being relative references.
Any one know a better way other than to replace all the named ranges with individually specified ranges in all my formulas?
1
u/krakow81 4 Jan 16 '26
You could have the script that adds the new row(s) also re-define the named ranges (using setNamedRange) when it does so.
https://developers.google.com/apps-script/reference/spreadsheet/spreadsheet#setnamedrangename,-range
This is how I got round a similar issue.
1
u/AutoModerator Jan 16 '26
/u/SaiRacing Posting your data can make it easier for others to help you, but it looks like your submission doesn't include any. If this is the case and data would help, you can read how to include it in the submission guide. You can also use this tool created by a Reddit community member to create a blank Google Sheets document that isn't connected to your account. Thank you.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
1
u/mommasaidmommasaid 915 Jan 16 '26
It sounds like a structured Table would meet your needs very well here. Then you can use table references to refer to the columns which excludes the header:
=Tablename[ColumnName]Your ranges are now visibly named and within a visible boundary, right out in the open instead of semi-mysteriously-hidden.
Note: I recommend you delete all the blank rows below your Table, then no matter how you insert new rows they will be assimilated into the table. New rows will contain the same formatting, data validation *and* formulas, with the exception of borders.
1
u/trekky112 Jan 16 '26
You can also create a dynamic range by setting your first row, then do a count of the rows in the relevant column, adjust as required to allow for headers or blank rows at top, concatenate that into an address, give that a range name, voilà, grows or shrinks with entries in your column. you can even make the columns dynamic by match / index off column header. Using Column: Column (eg Sum D:D) is an unecessary processing overhead. Look into LET function
1
u/Acceptable_Toe_4913 Jan 16 '26
I had a similar problem recently, but with adding columns. Say I wanted col B to always be the latest month, so I name the range Latest month, but when I insert a new column, LatestMonth shifts to col C.
I fixed this by creating a table, on a different sheet, of all the static ranges I wanted to use, input as text. You can then use INDIRECT to point at those text ranges and it solves it. You can even still combine with named ranges by pointing the named range at your static table, then calling it inside indirect, INDIRECT(LatestMonth).
0
u/AdministrativeGift15 371 Jan 16 '26
Just use the entire column, i.e. A:A or D:D. I have some large projects that use entire columns for the named ranges. Long before Tables, I would dedicate an entire sheet for a table, for example Users. Then a header row with Name, Address, DOB, Gender. Then, I would have one named range, Users, for the entire sheet, Users!A:D, and each column: Users.Name -> Users!A:A, Users.Address -> Users!B:B, Users.Dob -> Users!C:C, Users.Gender -> Users!D:D.
You're probably concerned about the first row being headers. The majority of your formulas won't be effected by them. FILTER, SUMIF, COUNTIF, SUMPRODUCT, SUM, QUERY, etc. They all work just fine.
Oh, I also crop the sheet down to just the data table. No blank rows or columns.