Is it possible to mass edit formulas in Google Sheets? - google-sheets

Is there a way to speed up the editing of hundreds of lines of formulas across many tabs in the same Google Sheet?
This is a followup question to: References changing in Google Sheets with new forms submissions ; which is about every time a new row is added in Google Sheets by a new submission from a Google Forms, some formulas change their references even if they are fixed with $ (Still no idea why that happens). The solution is to add INDIRECT to the formulas. However, there are too many formulas to comfortably change manually.
For example I have formulas like:
=COUNTIFS('Resp'!$AM$56:$AM,"Conf",'Resp'!$B56:$B,"PC
Arr")
It needs to change to :
=COUNTIFS(INDIRECT("Resp!$AM$2:$AM"),"Conf",indirect("Resp!$B2:$B"),"PC
Arr")
Search and replace wouldn't work because the way formulas are written, and there are quite varied types of formula and referenced columns (although the reference must change from 56 to 2) and the " ' " in the middles need to disappear.
Is there a way to speed up these changes even a bit or is it inevitable manual labor?

the only way how to mass-change formulas in Google Sheets is via CTRL + H where you can do it like this:

I found a mechanical way to lessen the amount of work to change many different formulas, but let me start with a general case first.
Option 1- For when the same formula repeats identically.
Search and replace (Ctrl+H) works well if you have the same formulas repeated all over. In this case it's viable to change massively, or once and then drag as needed.
However...
Option 2- When you have dozens of formulas that may be just slightly different or just too similar that 'Search and replace' (Ctrl+H) wouldn't work.
More so, if it's just so different that you cant drag the formula (like the reference changing to a new column and writing a different text based on that), then unfortunately you need to manually change things.
The solution I'm using to lessen the work was to use a programmable keyboard (in my case programmable+multimedia keyboard - Steren COM-6490 , up to 15 macros).
I used it to write down: INDIRECT(" , ") and $2 mainly, and then all the other mayor parts of text,references or formulas that do repeat with just 1 key each. Making a duplicate of your current formula on another sheet and have it open too in order to copy-paste stuff to complement the formulas also helps.

Related

Preventing API edits from breaking arrayformula columns

I have a Google Sheet that I'm using as a database for a an app I am building in AppSmith. Really just an interface for people to work with the sheet in a controlled manner.
I'm using the Google Sheet because I'm familiar with layering formulas to make it work the way I want it to work. I have a number of columns that start with an ARRAYFORMULA that gives the name of the column in row 1, blank in blank rows that should be blank, and some programmed information in other rows.
This works great as long as I am working from the spreadsheet or reading/adding rows from the app.
However, when I try to edit the row from the app, the API update will take the "50" that it sees in the column and actually put "50" in the cell, breaking the arrayformula.
Is there any way to prevent API calls from actually editing that column? Or to automatically clear the cell and let the arrayformula expand again?
I found a temporary workaround to push "" for the column(s) I know are arrays, but it seems vulnerable to complications if I add other array columns later, or want to make another form in the app that also updates the sheet.
As a "rule of thumb", avoid having formulas on sheets being used as "databases" (top row used for field names, 2nd row and below used for data). If you really need to use formulas in the spreadsheet instead of doing the calculations on the "APP", add them on a "mirror" sheet.
This is a common recommendation when using ARRAYFORMULAS to do calculations with data comming from Google Forms.
If you think that creating a "mirror" sheet might cause more problems than benefits, if your "APP" is able to limit the number of columns being edited, put the formulas to the right of the last column linked to the app.
Related
Make Google Spreadsheet Formula Repeat Infinitely

Google sheets, two-sheet dependent conditional formatting

My problem is probably trivial ... However, I was looking for similar problems and their solutions either do not work for me or I can not apply them.
I have 2 sheets - SheetA and SheetB. They are identical. I want to select every cell in SheetA that is no longer identical to Sheet B.
I was able to use (found here on Stack Overflow) such a function in conditional formatting:
= A1 <> INDIRECT ("SheetB! A" & ROW ())
It works if the range is column A. I know that I can apply this function to each column separately, but there is certainly a way that I can apply the same formula to the whole worksheet.
Will there be anyone who can show me the correct formula?
Edit: I tried to use above formula to every column... And my file become to work very slow... So whoever wants to do the same... think again.
After some tries I decided to move everything from SheetB to SheetA. I paste it a 1000 rows under data of Sheet A. Works fine without "indirect" function. No slow downs. It is not a perfect solution but it works.
But even after my problem is solved different way, I would like to know what is the correct formula for my problem... it might be useful for the future with smaller amount of data.
Solved ;)
You should be able to use the Address function to get the address of the current cell from its row and column:
=A1<>indirect("sheetB!"&address(row(),column()))
or for case-sensitive match:
=not(exact(A1,indirect("sheetB!"&address(row(),column()))))

How to combine dynamic ranges with OFFSET and INDIRECT functions?

I'm trying to create a formula that uses a dynamic range to link to the different tabs. It would then return the last 12 values before a blank cell, based on the value in the Header Column.
The tricky part is the data in each tab is of different sizes, so I thought it might have to incorporate either Offset(Blank()),0,-12) or something of the sort. I've tried a lot of different things, and this is the latest effort:
=Index(Indirect(A2&"!A9:AK9"),match("Conversions",Indirect(A2&"!A9:AK9"),)0,-12)
Edit: First post, sorry for the confusion. My goal is to make a large dashboard that has a dynamic chart using our monthly metrics. (I'm leaving the chart setup for another day)
The data varies in such, some have columns A:K, while some have a larger range of A:AK , etc. (With A:A being text). Since I've posted this, I have had some success by using Filter(), but the problem I'm not sure how to solve is finding the last 12 values before a blank cell.
Example of Data 1
Example of Data 2
Hopefully this helps explain the situation and I appreciate everyone for help.

Lock multiple cells in Google Spreadsheets with absolute reference ($)

Is there anyway to add a $ in front of all the cell references for formulas in my Google Spreadsheets without hand typing them in?
Ex: =Sheet1!H164 -> =Sheet1!$H$164
I have hundreds of formulas I need to do this for. I understand that F4 is a hotkey, but it would take years to lock the cell references that way.
For a column of formulae such as you show, select the column, Edit, Find and Replace..., Find !H. Replace with !$H$, check Also search within formulae and Done. Need to watch the likes of Wow!How was that possible but an entire sheet this way rarely takes a lot of Find/Replace, if reasonably well-structured.
I also recommend to use Find and replace (e.g. Find !A. Replace with !$A$)
But attention: If your sheet has entries in more than 26 columns, you would affect columns after Z, e.g. AA1 would become $A$A1 which will fail. You have to go through them afterwards manually and correct.
My solution is to use the INDIRECT formula.
Let's take an easy example. We want to apply =$A$1 to the entire a row.
Replace =$A$1 with =indirect("$A$"&row(A1)).
The INDIRECT formula can be dragged down as far as you want or combined with ARRAYFORMULA to do it automatically e.g.
=arrayformula(indirect("$A$"&row(A1:A100)))
(if you want to apply absolute referencing up to the row 100).

Google Spreadsheet Import Range #REF! Error (Randomly)

This problem has been persistent for a while, just happens every so often at random times, nothing changing. I also do not know how to reproduce the problem, but I'll give a detailed explanation of what's happening.
Normally the importRange function works just fine, and looks something like the following:
The Spreadsheet key is typed correctly - I've been using this strategy in Google Spreadsheets for a while now.
Every so often, Google Spreadsheets seems to break down, or at least the importRange function does... and produces something like the following:
Google seemed to be freezing up at times today, which is when this happened. I've tried adjusting the importRange parameters to !X1:X, !X2:X5, changing the title of the Sheet that is being imported, etc.
In the past, changing from !X:X to !X1:X fixed some columns, but not always all of them. The only fool-proof solution to fixing this, that I have found, is recreating both spreadsheets. As the back-end (the one being imported) eventually becomes a report, I would like to spare my boss the extra effort of referencing multiple spreadsheets, and would rather just fix this and be done with it.
Does anyone know the potential cause of this glitch? Sometimes it fixes itself, sometimes it doesn't. It happens randomly, and only to certain spreadsheets (I have a set of 8 or so that all use importRange, and no more than 2 are ever affected at the same time). So I honestly have no clue where this is coming from.
Side note: Google in general has been a bit unresponsive today in terms of all its services - my university's App Engine email service was down for about half an hour. Could a limitation on resources/network attackers be causing this kind of behavior in Spreadsheets?
Update: I attempted to import to the same Spreadsheet data from a different Spreadsheet (i.e., gave the importRange function a different Spreadsheet key). Though the key and range are valid if imported into a different Spreadsheet, in my original (the one full of #REF!), that range is not imported correctly. This leads me to believe that this glitch may apply only to a single Spreadsheet, where any attempt to importRange from any other source is not functional.
This is a little late, but I came across it in a search so it might help someone else - try something like this:
=IFERROR(ImportRange(SpreadSheet_GUID,"Bookings!P:P"),
IFERROR(ImportRange(SpreadSheet_GUID,"Bookings!P:p"),
IFERROR(ImportRange(SpreadSheet_GUID,"Bookings!p:P"),
ImportRange(SpreadSheet_GUID,"Bookings!p:p"))))
Basically the idea is to force Google to recalc using variations of the original address (upper/lower case column letters).
The problems with the IMPORTRANGE() function has been somewhat of an ongoing issue. There have been several bugs over the years and it is up to Google to find a stable solution so it works as designed.
Until then, this might help you:
Instead of editing the cell, creating a new spreadsheet, or doing anything else to have the sheet reattempt the function (almost like playing lottery), you can force Google sheets to reattempt the function automatically when it fails to load:
Wrap the IMPORTRANGE() function that is causing problems with an IFERROR() function. That way, the sheet attempts the import, and only if it fails, it attempts it again. The function can be nested to attempt several times in a row.
You can add named ranges to your source data (right-click-source>define-named-range) to facilitate. For instance, you can create 3 different named ranges for the "J:J" range. Call them "J", "Ja", and "Jay", then you call on your IFERROR() function in the sheet you want to import to:
=IFERROR( IMPORTRANGE( "SheetID","J" ), IFERROR( IMPORTRANGE( "SheetID","Ja" ), IFERROR( IMPORTRANGE( "SheetID","Jay" ), IFERROR( IMPORTRANGE( "SheetID", "'TabName'!J:J" ), IFERROR( IMPORTRANGE( "SheetID", "'TabName'!j:j" )))))
This formula will attempt your import and deliver it if it succeeds, and if not reattempts a total of 5 times in a row automatically, which doesn't guarantee you will succeed, but if you have a 50% chance of success with your imports, nesting 5 in a row should give you a 96% chance, which is a lot better. My personal experience has been that it hasn't failed since I've done the IFERROR() nest.
Hope it helps.
I had similar issues, and were resolved by NOT using public links to spreadsheets.
I have noticed that links are different for public sharing and those coppied from address bar while sheet si opened.
Also i have noticed some difficulties while opening shared spreadsheets from my other Google accounts. I had to re-allow access for some spreadsheets that i was importing.
Sorry for my english.
This happens, indeed, in my case simply Ctrl+X, waiting for a second, and then pasting the formula back makes the Sheets engine re-do the import and then it succeeds to import.
In case you can not do this procedure manually, you should use Tim's solution.
I found this solution, work fine for me:
In both spreadsheets insert an =now() equation in a random cell, say Z1
In both spreadsheets insert an =importrange() function that references the now function of the other spreadsheet.
Go into your spreadsheet settings and choose to recalculate every minute.
I tried a lot of other suggestions including using the =now() function, the now URL trick in this thread, or Apps Script to insert random text on a set interval, but nothing would force importrange to update except a manual edit of the source sheet.
https://webapps.stackexchange.com/questions/60324/how-can-i-get-google-sheets-to-auto-update-a-reference-to-another-sheet
I had the same issue, and found a solution!
Please reduce the source file's size
To reduce, split it up and again have the import-range referenced
You now will be able to see the imported range!
If you think the above isn't the situation, the chances might be
Your cell is occupied so remove all formatting and clear all the cells before importing the range.
Still not working? Let God help you out!
I tried adding :
if(ISERROR(importrange...
and it works.
It doesn't mean the error disappears, but when it happens, you just need to reload the sheet and wait for while and let it update itself.
It is much more practical than manually changing the big letter to small letter.
Here's the easy work-around I've found for this bug:
I do a Find-and-Replace ("search within formulas") for "=" wherever I have the importrange error (=REF!) (or just for the whole sheet) and I replace-all with a "#" in order to make it all be text rather than formula. Then I do another Find-and-Replace over the same area and replace-all the "#" with "=" again. This consistently fixes the issue.
I was able to fix the =REF! error using the Edit > Find and Replace > Find "=" Replace with "#" > Search Selected Range > Also search within formulas > Find > Done. The error corrected without actually initiating the Replace command.
just to share with you how I resolve this error.
Upon checking on my formulas, I have a Circular Reference, which made me encounter this ImportRange internal Error. When I clean my formulas to remove those circular references, it worked again. :)
I had the same problem and solved it by using
=IF(ISERROR(A1);IMPORTRANGE();IMPORTRANGE())
in the cell where earlier IMPORTRANGE used to be and by turning on Iterative calculation in spreadsheet’s location & calculation settings.
Hope it help someone

Resources