Follow formula patterns for some cells only - google-sheets

I am trying to get excel to follow patterns grabbing information from cells only, while keeping other cells in the formula static.
As follows:
=importxml(CONCATENATE(A1,B17),E1)
A1 = never changes
B17 = increments by 1 every time. Ex: B17, B18, B19, etc...
E1 = never changes
Right now it seems like excel is counting the number of cells from the cell I am currently in and once I try to follow that pattern it keeps counting the same number of cells to grab the cell in the pattern. (Ex: 7 cells up, so as I move down from the current cell it keeps looking for data in the cell 7 cells up from the current one, which is often, empty). Moreover, right now all cells are changing in the pattern and I only need SOME cells to follow the pattern.
I appreciate any help with this.

If I understand your question, you want to copy that formula while keeping the first and last parameters (A1 and E1) constant. That can be achieved by using the $ sign:
$A$1 will always be copied as $A$1
$A1 will be copied as $An where n is the row number - so if you copy it one row down (whatever the column) it will become $A2
A$1 will be copied as XX$1 where XX is the column - so if you copy it one column to the right, (whatever the row) it will become B$1
So in your case you would use:
=importxml(CONCATENATE($A$1,B17),$E$1)
or if you need to make the B column constant (but not the row):
=importxml(CONCATENATE($A$1,$B17),$E$1)

Related

Issue with conditional formatting cell range based on exact match text in one cell

We track workshop registrations in a google sheet and I'm trying to conditionally format a range of cells (A7:P14) based on the text in cell E7 (Eng DLO, Eng TBC, Sp DLO, Sp TBC).
I used the formula
=COUNTIF($E7:$E, "Eng DLO")
and A7:S14 turned the selected color (light purple). When I then added conditional formatting to turn dark purple with the formula
=COUNTIF($E7:$E, "Eng TBC")
the color wouldn't change when I changed the value in E7 from Eng DLO to Eng TBC.
I know the issue is that I need it to EXACTLY MATCH the text and I tried incorporating EXACT into the COUNTIF formula, but it would only highlight E7 or just A7:P7 instead of the whole selected range in the conditional format (A7:P14).
Here is a sample sheet with what I am hoping it will eventually look like once I get the conditional formatting to actually work (I removed the conditional formatting). https://docs.google.com/spreadsheets/d/1Bn9FVTHE1OO49p4PKo6j0Qd3c0NX6pUq3vp0pHFNGVI/edit?usp=sharing
Got a couple other issues here:
The 7 is a floating reference, so you need to fix it with $. This is the reason your formula isn't working. In the next row, it would start counting in cell E8. With the $, it works, but less efficiently than it could, which brings me to point 2.
If you're only referencing one cell, just check for equality against that one cell.
To the Eng TBC, you would use
=EXACT($E$7, "Eng TBC")
Just to demonstrate a point, without the dollar sign, the next rows cells would have been checking against this:
=EXACT($E8, "Eng TBC")
Which of course would have been empty.
A More Flexible Solution
Since you probably don't want to keep having to reformat per set of cells, you can use a ROW-based approach to tackle the issue. This one, for example, assumes 8 seats per group.
=EXACT("Eng DLO",INDIRECT("E"&(8 * INT((ROW() - 7) / 8) + 7)))
Every 8 rows, it references the next multiple of 7. (Yes, INT is FLOOR, but shorter.)

How to reference vertical cells on a separate sheet horizontally (but every nth cell horizontally)

Just to preface this is quite a unique ask and I've googled a bunch of times and never seen the combination of these factors being asked before.
Essentially I have 2 sheets. 'Sheet' & 'Sheet2'
'Sheet' has
A1:3
A2:4
A3:8
A4:4
And So on with random amounts for a few hundred cells. I want 'Sheet2' to display the following and allow me to drag it to extrapolate it. The reason it is every nth cell is because those cells are merged (i.e A1-D1 is merged).
A1:('Sheet1'A1) E1:('Sheet1'A2) I1:(Sheet1'A3) M1:('Sheet1'A4)
and so on
I can extrapolate the data with =OFFSET(Sheet!$A1,COLUMN()-1,0) but it skips the missing data on cells A2 & A3 and creates A1:('Sheet1'A1) E1:('Sheet1'A4) instead.
A simple pull-across formula would be
=index(Sheet1!$A:$A,(column()+3)/4)
Or an array formula
=ArrayFormula(vlookup((column(2:2)+3)/4,{row(Sheet1!A:A),Sheet1!A:A},2))
Assuming there are enough merged cells available to hold all the data in sheet 1.
Sheet 1
Sheet 2

How to use ARRAYFORMULA with OFFSET to previous row without getting circular reference error

Example sheet: https://docs.google.com/spreadsheets/d/14ma-y3esh1S_EkzHpFBvLb0GzDZZiDsSVXFktH3Rr_E/edit?usp=sharing
In column B of ItemData sheet, I have achieved the result I want by copying the formula into every cell in the column, but I want to solve this using ArrayFormula instead.
In column C I have achieved the same result using ArrayFormula. However, for addition, column C is referring to cells in column B, while column B is referring to cells in column B. I.e. every cell in column B is adding 1 to the cell on the row above.
If I select the C3 formula text and paste it into the cell edit field for cell B3 (to not screw up cell references during copy - I know I could make them static references, but this is not my problem), the cell gets an error value of
#REF!
Error
Circular dependency detected. To resolve with iterative calculation, see File > Spreadsheet Settings.
Do note that the additions that need to be done are the same in both cases: Add 1 to the value of the cell on the previous row, so there is no circular reference involved. There is a starting value provided in B2, and cells in B3 and downwards should use the data from the B cell in the previous row.
Also, note that I did try File->Spreadsheet settings and enabling circular reference computation with max 25 items, but this only fills in the first two cells (B3 and B4).
How can I solve this problem? I would prefer having something like ArrayFormula, where the formula only exists in a single cell. But copy-pasting would be acceptable as long as any new rows, inserted in between or added at the bottom, would get the same formula added in column B.
Will matching items always be consecutive? It seems that way since you're comparing each Item cell to the cell above it right in your formula logic. That breaks an [unwritten?] rule of spreadsheet normalization; values' addresses themselves generally should not be treated as data.
IF you're committed to it though, have you considered explicitly using location as a data source? Example:
=ARRAYFORMULA(IFS(
NOT(LEN(A3:A40)),,
ROW(A3:A40)-3-MATCH(A3:A40,A$3:A$40,0)<=VLOOKUP(VLOOKUP(A3:A40,Items!$A$2:$D,2,false),DataPerColor!$A$2:$B,2,false),ROW(A3:A40)-3-MATCH(A3:A40,A$3:A$40,0),
true,
))
Just like your formulas, all that does in English is:
for each row,
if there's no Item, don't output any ItemData,
if the number that belongs in this cell¹ is less than or equal to the lookup, print it,
otherwise, don't output any ItemData
But then what is ¹ "the number that belongs in this cell" and how can we calculate it without using column B? I abuse locations of things to get it. Looking down your row B, each number that appears is just:
this row's number,  minus  
the row where items start [always 3],  minus  
the row number [in just the Item rows] of the first row containing this row's Item
Using the second-to-last ItemC as an example: the first ItemC is the 16th item listing, and the one we're looking up… the "second-to-last ItemC" is in row 21 of the sheet. 21-3-16 = 2 …the number you wanted.
If you can stomach that, it's a single formula and does work according to your specifications.

Multiple Layers of Matching Blank Cells

I'm back with another Google Sheets question. This one isn't scripting though - this time I'm looking for help in figuring out a formula.
I've attached screenshots of two sheets. The first one features one "opposing party" at row 8. The second one features an opposing part at row 8 and a second opposing party at row 9. Cell B3's formula is shown in both; in essence, Cell B3 looks for the first blank cell in column L after Row 10 (or Row 11 in the second image) and returns the contents of that row's "F" column. This allows me to "get" the next deadline in the matter that is being tracked. For those interested, yes, Cell D3 has a similar formula looking at K.
Currently, we have to manually update B3 (and D3) if we add additional parties (not necessarily opposing, and not just one either). This is more tedious than I would like. I would like a formula that would return "F10" and "L10" in situations where only one opposing party appears, "F11" and "L11" if there is an additional, and so on so that even if we have a massive, multi-party action it will still return the next cell.
If it helps, you can always assume that there will be a blank set of cells below the last "opposing party" and the row that we want to start querying (as shown in the second image).
I'd love any help that you can give. Please let me know if you need anything clarified.
Thanks a ton!
--Databoy2k
Is this what you require for B3?
=index(F:F, match("rule", I:I, 0)+1)
In a larger scope use,
=index(indirect("F"&match("Rule",I:I,0)&":F"), match(TRUE, index(isblank(indirect("L"&match("Rule",I:I,0)&":L")),0,0),0))
I think the easiest way would be to make the cells you are referencing a named range. That way, you can add as many other rows, columns, cells, whatever, and your formula will always reference the same range of cells.
For example, you could name the range of cells in column F 'Steps', and in K 'Deadline', then change your formula to =index(Steps,match(TRUE, index(isblank(Deadline),0,0),0)), and it will always give you the correct range.
Here's a pic to show how to name a range (right-click on the selection).

How to use arrayformula to dynamically join strings in google spreadsheet?

I use Arrayformula() to make my reports dynamic and easier to edit. For example, if I have a Column A with a list o number o blue balls in a set and a Column B with a list red balls in a set, on the cell C1 I can write =ArrayFormula(add(A1:A,B1:B)) and in the Column C will have the total of balls in each set. It would be exactly the same as writing =A1+B1 in cell C1 and dragging the formula down to the last row. Arrayformula() has some benefits, because it will work if some adds or removes rows from the sheet and also it makes the reports way more organized and easier to edit.
Since I´ve discovered arrayformula(), my life has changed, because of the fact that googleSheets expands the formula to other cells. It does not work every time, but the idea of expanding to other cells seems to be possible some way or another, here is a good example of a problem that was not resolved by arrayformula(), but has the same idea.
Keeping that idea in mind, imagine that on Column A there is a list of First Names and on Column B there is a list of Last names. On Column C I want to join this two string using a simples space. The way to do that would be in the cell C1 write =join(" ",A1,B1) and then drag down this formula. This method method however is prone to error since people can add and remove rows, deleting my formula. I want to use a formula that I can write in one single cell and it expands to other cells. I´ve tried =arrayformula(join(" ",A1:A,B1:B)), but it does not work.
Is that a way to do that using =arrayformula() or other native function?
I know I could write a script or custom formula to do that, but this is not my goal here.
I think this formula should work:
=arrayformula(A1:A&" "&B1:B)
In case you want to use a delimiter, you can do the following to have a clean result even though, A or B is not present in some cases:
ARRAYFORMULA(ifna(ifs(isblank(A1:A),,ISBLANK(B1:B),A1:A),A1:A&" - "&B1:B))

Resources