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

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.

Related

Conditional formatting based on adjacent cell value even when the first adjacent cell in row is blank

I would like to colour cell C3 red, as the value is less than the next filled cell on row 3 (E3).
You need custom formula in the formatting rules for range C2:W.
And you can use the formula below for green:
=and(not(isblank(C2)),C2>index(filter(D2:$W2,arrayformula(not(isblank(D2:$W2))))),1,1)
And make another conditional formatting rule with the same range and change > accordingly for red.
Note that the equal case does not have formatting in your example.
To understand why, there are a few components at work. I'll give an outline in case OP or any passer-by wants one.
First is how conditional formatting in Google Sheet works. I will be brief here. The range we put in the rule is C2:W. Google Sheet will use the beginning cell in that range as a reference. For C2:W, the 1st cell is C2. In the formula, the cells are read in terms of relative position to that reference cell. So when evaluating formatting for cell C2, it treats the formula as is. But, for example, when evaluating formatting for cell C3, Google Sheet iterates all non-fixed ranges by 1 row. Another example: for D3, all non-fixed ranges are iterated by 1 row and 1 column.
Whenever the formula evaluates to true, the format will be applied -- although that is subject to further formatting if you have subsequent formatting rules which apply to the given cell.
Next are the components of the conditional formula.
not(isblank(C2)) checks for blank cells and makes the whole formula only true when the cell is non-blank.
For filter() usage, please consult official documentation. I will explain how filter() is applied to your example.
In our use, we are trying to rid of empty cells in the range that is on the same row as the cell in question and goes from the next column to column W. (I am using column W because there is no known end column in your image. Please adjust to your application accordingly.) Same row as C2 means row 2. Hence the digit 2 in D2:$W2. No $ sign for row because row index is meant to iterate through our range C2:W in the formatting rule. No $ sign for D because we mean 1 column next to the cell in question and the exact column index should iterate. We fix column W because the end column does not evolve and is thus not meant to iterate. Neglecting this will not particularly change the result in your example. However, it is good to be clear with the meanings.
arrayformula(not(isblank(D2:$W2))) produces a local row array whose cells are true/false that each represents whether the corresponding cell is non-blank. filter() in turn only keeps cells from D2:$W2 for cells in arrayformula(not(isblank(D2:$W2))) that are true.
We only care about the 1st non-blank cell. To retrieve the 1st cell from a (local) array, we use index(...,1,1). (That said, omitting index() also happens to work for the 1st cell in particular because when comparing a single cell with > or < to an array range, only the 1st cell of the array is used.)
Apply a conditional formatting to the range desired (starting from cell C2) using this formula:
=IF(C2="",FALSE,OFFSET(C2,0,AGGREGATE(15,6,(COLUMN(D2:W2)-COLUMN(D2)+1)/(D2:W2<>""),1))>C2)

How can I use arrayformula so I got the cell value that used last time?

I have a table of content on google sheet where word list on column B and image name on column C. On column C image name is not given for every cell. Now I need to use ARRAYFORMULA on Cell D1 where it will give the output (Word name and Image Name) on Column D if Row of Column A is not empty. If you look at the attached screenshot, for some Word there is no image name given on column C. In this case I need the image name that used last time.
For example: On Row 17 for WORD 4 there is no image name given. So, in this case the image name will be Image 2 from cell C12 that used previously for WORD 3. I tried it in many different ways but never able to do it with ARRAYFORMULA. The only solution I am using right now is using formula for every row which is not a good solution. I need to do it with ARRAYFORMULA. I don't want to do it with google script.
➡ Spreadsheet link (Please check Tab 1)
➡ Please check the Screenshot
I have added a sheet ("Erik Help") with the following formula in D1:
=ArrayFormula({"Header";IF(A2:A="",,B2:B&" : "&VLOOKUP(ROW(A2:A),FILTER({ROW(A2:A),C2:C},C2:C<>""),2,TRUE))})
This one array formula creates a header and then fills the entire column with results.
You can change "Header" to whatever you like.
IF(A2:A="",, just leaves D2:D null if nothing is in that row of Col A.
Otherwise, whatever is in B2:B is concatenated with a space-colon-space and then a VLOOKUP of all rows within a FILTERed virtual array that contains only rows and Col-C data where Col C is not blank. Because TRUE is chosen as the final parameter, all rows will "look backward" to the last row where Col C did contain data and return that data as the final piece to be concatenated.
=if(isnumber(SEARCH("WORD",B2,1)),join(" : ",B2, indirect(ARRAYFORMULA(address(IFNA(match(2,1/($C$2:$C2<>"")))+1,COLUMN(C2))))),"")
past this formula in D1 cell and drag it ...

Getting error "Array result was not expanded because it would overwrite data in C3."

I have a google sheet in which I have two tabs.
I want to add the data of Column 1 from tab 2 transposed to Rows in Tab 1 of the same google Sheet.
Tab 1 name: Student
Tab 2 name: Landlord
Column in Landlord tab: College
I applied the formula =Transpose(Landlord!B2:B). It gave me the error "Array result was not expanded because it would overwrite data in C3."
How can I get rid of this error?
Issue:
It is failing because of the conflict of data in C3.
Fix:
What you need to do is either remove/move the data in C3 currently, or move the transpose formula to a row that doesn't have any data so it won't have any conflict.
Your case:
Transposing B2:B is a very long range so it might have been able to occupy the whole row and base on your error, your formula is either located in either A3 or B3. You need the formula to be on a cell where its row is blank. So either move the formula to another row with no data, or delete all data in row 3.
Sample:
As seen above, =transpose(A1:A4) won't expand because of x value in C5. To proceed, we need to either remove/move C5 value, or move the formula
Output:
Move all conflicted cells/data into another row
Delete row 5 data aside from the formula
Move the formula to a blank row

How to count rows between 2 non empty cells with their intermediary empty cells in Google Sheets?

I'm trying to count each rows of empty cells between two non-empy cells and adding the upper non empty-cell count (or the lower non-empty cells count) to the result when the empty cells/rows numbers are variable and irregular in this manner:
A1 Empty
A2 Non-empty
A3 Empty
A4 Empty
A5 Empty
A6 Empty
A7 Non-empty
(with A2 to A5 being irregular — could be any number of intermediary empty rows/cells — i.e. 10, 2, 30, 5, etc., and variable — could be located in any location within Column A)
The result should return as follow:
=IFS(
AND(A2="",A3=""),"",
AND(A2="",A3<>""),"",
AND(A2<>"",A3<>""),ROWS(A2),
AND(A2<>"",A3=""),ROWS(A2:UP TO NEXT NON-EMPTY ROW BENEATH (NOT COMPRISED (or minus the next non-empty row(-1)))
How do we program Google Sheets to count rows "UP TO NEXT NON-EMPTY ROW BENEATH (NOT COMPRISED (or minus the next ono empty row(-1)) when the emppty intermediary rows' count is variable/unknown for each occurence and irregular/can be any number of intremediary rows?
I have this data as example:
So far, I've come up with this partial solution:
=IFS(AND(A2="",A3=""),"", AND(A2="",A3<>""),"", AND(A2<>"",A3<>""),ROWS(A2), AND(A2<>"",A3=""),ROWS(A2:UP TO NEXT NON-EMPTY ROW BENEATH (NOT COMPRISED (or minus the next non-empty row(-1)))))
The expected result should return as follows:
The Sheet copy:
https://docs.google.com/spreadsheets/d/1eLXdFINKVtS5Fxon8mIQDmBUTZokyY_Fb6tfWJRDOVI/edit?usp=sharing
Well I think you can do it a bit more elegantly using a reverse lookup. The idea is to sort the data on descending order of row number, then use a match with -1 as the last parameter, which is equivalent to searching from the end of the data for the next non-blank.
=ArrayFormula(iferror(if(A2:A="","",rows(A2:A)+2-match(row(A2:A)+1,
query(SORT({IF(A2:A<>"",row(A2:A),""),row(A2:A)},2,false),"select Col1"),-1)-row(A2:A)),1))
If you wanted to keep it simple and just use a pull-down formula, an ordinary match is enough:
=ArrayFormula(iferror(if(A2="","",match(true,A3:A<>"",0)),1))
(it still has to be entered as an array formula because A3:A<>"" is an array of True and False)
I found a solution with a Monster formula but with simple iterative logics, and up to 50 intermediary blanks (for more only need to make the formula larger).
What I was lookind for was simply to print the cells/rows count of intermediary empty cells between 2 non-empty cells + adding to the count either the 1st non-empty cell or the last non-empty cell.
So for example if cell A1 and cell A9 have 8 empty cells between them, then return 8+1 (or 10-1).
The logics used is simple:
probe how many possible empty cells there can be between each 2 non-empty cells counting the 1st non-empty as well within column A (in the formula below the possibility is up to 50 empty cells), and for each case return the intermediary rows -1 (the last row).
The formula:
=IFS(AND(A1="",A2=""),"",AND(A1="",A2<>""),"",AND(A1<>"",A2<>""),ROWS(A1),AND(A1<>"",A2="",A3<>""),ROWS(A1:A3)-1,AND(A1<>"",A2="",A3="",A4<>""),ROWS(A1:A4)-1,AND(A1<>"",A2="",A3="",A4="",A5<>""),ROWS(A1:A5)-1,AND(A1<>"",A2="",A3="",A4="",A5="",A6<>""),ROWS(A1:A6)-1,AND(A1<>"",A2="",A3="",A4="",A5="",A6="",A7<>""),ROWS(A1:A7)-1,AND(A1<>"",A2="",A3="",A4="",A5="",A6="",A7="",A8<>""),ROWS(A1:A8)-1,AND(A1<>"",A2="",A3="",A4="",A5="",A6="",A7="",A8="",A9<>""),ROWS(A1:A9)-1,AND(A1<>"",A2="",A3="",A4="",A5="",A6="",A7="",A8="",A9="",A10<>""),ROWS(A1:A10)-1,AND(A1<>"",A2="",A3="",A4="",A5="",A6="",A7="",A8="",A9="",A10="",A11<>""),ROWS(A1:A11)-1,AND(A1<>"",A2="",A3="",A4="",A5="",A6="",A7="",A8="",A9="",A10="",A11="",A12<>""),ROWS(A1:A12)-1,AND(A1<>"",A2="",A3="",A4="",A5="",A6="",A7="",A8="",A9="",A10="",A11="",A12="",A13<>""),ROWS(A1:A13)-1,AND(A1<>"",A2="",A3="",A4="",A5="",A6="",A7="",A8="",A9="",A10="",A11="",A12="",A13="",A14<>""),ROWS(A1:A14)-1,AND(A1<>"",A2="",A3="",A4="",A5="",A6="",A7="",A8="",A9="",A10="",A11="",A12="",A13="",A14="",A15<>""),ROWS(A1:A15)-1,AND(A1<>"",A2="",A3="",A4="",A5="",A6="",A7="",A8="",A9="",A10="",A11="",A12="",A13="",A14="",A15="",A16<>""),ROWS(A1:A16)-1,AND(A1<>"",A2="",A3="",A4="",A5="",A6="",A7="",A8="",A9="",A10="",A11="",A12="",A13="",A14="",A15="",A16="",A17<>""),ROWS(A1:A17)-1,AND(A1<>"",A2="",A3="",A4="",A5="",A6="",A7="",A8="",A9="",A10="",A11="",A12="",A13="",A14="",A15="",A16="",A17="",A18<>""),ROWS(A1:A18)-1,AND(A1<>"",A2="",A3="",A4="",A5="",A6="",A7="",A8="",A9="",A10="",A11="",A12="",A13="",A14="",A15="",A16="",A17="",A18="",A19<>""),ROWS(A1:A19)-1,AND(A1<>"",A2="",A3="",A4="",A5="",A6="",A7="",A8="",A9="",A10="",A11="",A12="",A13="",A14="",A15="",A16="",A17="",A18="",A19="",A20<>""),ROWS(A1:A20)-1,AND(A1<>"",A2="",A3="",A4="",A5="",A6="",A7="",A8="",A9="",A10="",A11="",A12="",A13="",A14="",A15="",A16="",A17="",A18="",A19="",A20="",A21<>""),ROWS(A1:A21)-1,AND(A1<>"",A2="",A3="",A4="",A5="",A6="",A7="",A8="",A9="",A10="",A11="",A12="",A13="",A14="",A15="",A16="",A17="",A18="",A19="",A20="",A21="",A22<>""),ROWS(A1:A22)-1,AND(A1<>"",A2="",A3="",A4="",A5="",A6="",A7="",A8="",A9="",A10="",A11="",A12="",A13="",A14="",A15="",A16="",A17="",A18="",A19="",A20="",A21="",A22="",A23<>""),ROWS(A1:A23)-1,AND(A1<>"",A2="",A3="",A4="",A5="",A6="",A7="",A8="",A9="",A10="",A11="",A12="",A13="",A14="",A15="",A16="",A17="",A18="",A19="",A20="",A21="",A22="",A23="",A24<>""),ROWS(A1:A24)-1,AND(A1<>"",A2="",A3="",A4="",A5="",A6="",A7="",A8="",A9="",A10="",A11="",A12="",A13="",A14="",A15="",A16="",A17="",A18="",A19="",A20="",A21="",A22="",A23="",A24="",A25<>""),ROWS(A1:A25)-1,AND(A1<>"",A2="",A3="",A4="",A5="",A6="",A7="",A8="",A9="",A10="",A11="",A12="",A13="",A14="",A15="",A16="",A17="",A18="",A19="",A20="",A21="",A22="",A23="",A24="",A25="",A26<>""),ROWS(A1:A26)-1,AND(A1<>"",A2="",A3="",A4="",A5="",A6="",A7="",A8="",A9="",A10="",A11="",A12="",A13="",A14="",A15="",A16="",A17="",A18="",A19="",A20="",A21="",A22="",A23="",A24="",A25="",A26="",A27<>""),ROWS(A1:A27)-1,AND(A1<>"",A2="",A3="",A4="",A5="",A6="",A7="",A8="",A9="",A10="",A11="",A12="",A13="",A14="",A15="",A16="",A17="",A18="",A19="",A20="",A21="",A22="",A23="",A24="",A25="",A26="",A27="",A28<>""),ROWS(A1:A28)-1,AND(A1<>"",A2="",A3="",A4="",A5="",A6="",A7="",A8="",A9="",A10="",A11="",A12="",A13="",A14="",A15="",A16="",A17="",A18="",A19="",A20="",A21="",A22="",A23="",A24="",A25="",A26="",A27="",A28="",A29<>""),ROWS(A1:A29)-1,AND(A1<>"",A2="",A3="",A4="",A5="",A6="",A7="",A8="",A9="",A10="",A11="",A12="",A13="",A14="",A15="",A16="",A17="",A18="",A19="",A20="",A21="",A22="",A23="",A24="",A25="",A26="",A27="",A28="",A29="",A30<>""),ROWS(A1:A30)-1,AND(A1<>"",A2="",A3="",A4="",A5="",A6="",A7="",A8="",A9="",A10="",A11="",A12="",A13="",A14="",A15="",A16="",A17="",A18="",A19="",A20="",A21="",A22="",A23="",A24="",A25="",A26="",A27="",A28="",A29="",A30="",A31<>""),ROWS(A1:A31)-1,AND(A1<>"",A2="",A3="",A4="",A5="",A6="",A7="",A8="",A9="",A10="",A11="",A12="",A13="",A14="",A15="",A16="",A17="",A18="",A19="",A20="",A21="",A22="",A23="",A24="",A25="",A26="",A27="",A28="",A29="",A30="",A31="",A32<>""),ROWS(A1:A32)-1,AND(A1<>"",A2="",A3="",A4="",A5="",A6="",A7="",A8="",A9="",A10="",A11="",A12="",A13="",A14="",A15="",A16="",A17="",A18="",A19="",A20="",A21="",A22="",A23="",A24="",A25="",A26="",A27="",A28="",A29="",A30="",A31="",A32="",A33<>""),ROWS(A1:A33)-1,AND(A1<>"",A2="",A3="",A4="",A5="",A6="",A7="",A8="",A9="",A10="",A11="",A12="",A13="",A14="",A15="",A16="",A17="",A18="",A19="",A20="",A21="",A22="",A23="",A24="",A25="",A26="",A27="",A28="",A29="",A30="",A31="",A32="",A33="",A34<>""),ROWS(A1:A34)-1,AND(A1<>"",A2="",A3="",A4="",A5="",A6="",A7="",A8="",A9="",A10="",A11="",A12="",A13="",A14="",A15="",A16="",A17="",A18="",A19="",A20="",A21="",A22="",A23="",A24="",A25="",A26="",A27="",A28="",A29="",A30="",A31="",A32="",A33="",A34="",A35<>""),ROWS(A1:A35)-1,AND(A1<>"",A2="",A3="",A4="",A5="",A6="",A7="",A8="",A9="",A10="",A11="",A12="",A13="",A14="",A15="",A16="",A17="",A18="",A19="",A20="",A21="",A22="",A23="",A24="",A25="",A26="",A27="",A28="",A29="",A30="",A31="",A32="",A33="",A34="",A35="",A36<>""),ROWS(A1:A36)-1,AND(A1<>"",A2="",A3="",A4="",A5="",A6="",A7="",A8="",A9="",A10="",A11="",A12="",A13="",A14="",A15="",A16="",A17="",A18="",A19="",A20="",A21="",A22="",A23="",A24="",A25="",A26="",A27="",A28="",A29="",A30="",A31="",A32="",A33="",A34="",A35="",A36="",A37<>""),ROWS(A1:A37)-1,AND(A1<>"",A2="",A3="",A4="",A5="",A6="",A7="",A8="",A9="",A10="",A11="",A12="",A13="",A14="",A15="",A16="",A17="",A18="",A19="",A20="",A21="",A22="",A23="",A24="",A25="",A26="",A27="",A28="",A29="",A30="",A31="",A32="",A33="",A34="",A35="",A36="",A37="",A38<>""),ROWS(A1:A38)-1,AND(A1<>"",A2="",A3="",A4="",A5="",A6="",A7="",A8="",A9="",A10="",A11="",A12="",A13="",A14="",A15="",A16="",A17="",A18="",A19="",A20="",A21="",A22="",A23="",A24="",A25="",A26="",A27="",A28="",A29="",A30="",A31="",A32="",A33="",A34="",A35="",A36="",A37="",A38="",A39<>""),ROWS(A1:A39)-1,AND(A1<>"",A2="",A3="",A4="",A5="",A6="",A7="",A8="",A9="",A10="",A11="",A12="",A13="",A14="",A15="",A16="",A17="",A18="",A19="",A20="",A21="",A22="",A23="",A24="",A25="",A26="",A27="",A28="",A29="",A30="",A31="",A32="",A33="",A34="",A35="",A36="",A37="",A38="",A39="",A40<>""),ROWS(A1:A40)-1,AND(A1<>"",A2="",A3="",A4="",A5="",A6="",A7="",A8="",A9="",A10="",A11="",A12="",A13="",A14="",A15="",A16="",A17="",A18="",A19="",A20="",A21="",A22="",A23="",A24="",A25="",A26="",A27="",A28="",A29="",A30="",A31="",A32="",A33="",A34="",A35="",A36="",A37="",A38="",A39="",A40="",A41<>""),ROWS(A1:A41)-1,AND(A1<>"",A2="",A3="",A4="",A5="",A6="",A7="",A8="",A9="",A10="",A11="",A12="",A13="",A14="",A15="",A16="",A17="",A18="",A19="",A20="",A21="",A22="",A23="",A24="",A25="",A26="",A27="",A28="",A29="",A30="",A31="",A32="",A33="",A34="",A35="",A36="",A37="",A38="",A39="",A40="",A41="",A42<>""),ROWS(A1:A42)-1,AND(A1<>"",A2="",A3="",A4="",A5="",A6="",A7="",A8="",A9="",A10="",A11="",A12="",A13="",A14="",A15="",A16="",A17="",A18="",A19="",A20="",A21="",A22="",A23="",A24="",A25="",A26="",A27="",A28="",A29="",A30="",A31="",A32="",A33="",A34="",A35="",A36="",A37="",A38="",A39="",A40="",A41="",A42="",A43<>""),ROWS(A1:A43)-1,AND(A1<>"",A2="",A3="",A4="",A5="",A6="",A7="",A8="",A9="",A10="",A11="",A12="",A13="",A14="",A15="",A16="",A17="",A18="",A19="",A20="",A21="",A22="",A23="",A24="",A25="",A26="",A27="",A28="",A29="",A30="",A31="",A32="",A33="",A34="",A35="",A36="",A37="",A38="",A39="",A40="",A41="",A42="",A43="",A44<>""),ROWS(A1:A44)-1,AND(A1<>"",A2="",A3="",A4="",A5="",A6="",A7="",A8="",A9="",A10="",A11="",A12="",A13="",A14="",A15="",A16="",A17="",A18="",A19="",A20="",A21="",A22="",A23="",A24="",A25="",A26="",A27="",A28="",A29="",A30="",A31="",A32="",A33="",A34="",A35="",A36="",A37="",A38="",A39="",A40="",A41="",A42="",A43="",A44="",A45<>""),ROWS(A1:A45)-1,AND(A1<>"",A2="",A3="",A4="",A5="",A6="",A7="",A8="",A9="",A10="",A11="",A12="",A13="",A14="",A15="",A16="",A17="",A18="",A19="",A20="",A21="",A22="",A23="",A24="",A25="",A26="",A27="",A28="",A29="",A30="",A31="",A32="",A33="",A34="",A35="",A36="",A37="",A38="",A39="",A40="",A41="",A42="",A43="",A44="",A45="",A46<>""),ROWS(A1:A46)-1,AND(A1<>"",A2="",A3="",A4="",A5="",A6="",A7="",A8="",A9="",A10="",A11="",A12="",A13="",A14="",A15="",A16="",A17="",A18="",A19="",A20="",A21="",A22="",A23="",A24="",A25="",A26="",A27="",A28="",A29="",A30="",A31="",A32="",A33="",A34="",A35="",A36="",A37="",A38="",A39="",A40="",A41="",A42="",A43="",A44="",A45="",A46="",A47<>""),ROWS(A1:A47)-1,AND(A1<>"",A2="",A3="",A4="",A5="",A6="",A7="",A8="",A9="",A10="",A11="",A12="",A13="",A14="",A15="",A16="",A17="",A18="",A19="",A20="",A21="",A22="",A23="",A24="",A25="",A26="",A27="",A28="",A29="",A30="",A31="",A32="",A33="",A34="",A35="",A36="",A37="",A38="",A39="",A40="",A41="",A42="",A43="",A44="",A45="",A46="",A47="",A48<>""),ROWS(A1:A48)-1,AND(A1<>"",A2="",A3="",A4="",A5="",A6="",A7="",A8="",A9="",A10="",A11="",A12="",A13="",A14="",A15="",A16="",A17="",A18="",A19="",A20="",A21="",A22="",A23="",A24="",A25="",A26="",A27="",A28="",A29="",A30="",A31="",A32="",A33="",A34="",A35="",A36="",A37="",A38="",A39="",A40="",A41="",A42="",A43="",A44="",A45="",A46="",A47="",A48="",A49<>""),ROWS(A1:A49)-1,AND(A1<>"",A2="",A3="",A4="",A5="",A6="",A7="",A8="",A9="",A10="",A11="",A12="",A13="",A14="",A15="",A16="",A17="",A18="",A19="",A20="",A21="",A22="",A23="",A24="",A25="",A26="",A27="",A28="",A29="",A30="",A31="",A32="",A33="",A34="",A35="",A36="",A37="",A38="",A39="",A40="",A41="",A42="",A43="",A44="",A45="",A46="",A47="",A48="",A49="",A50<>""),ROWS(A1:A50)-1)
Here the images sheet of the result:
The Sheet
Can it be done in a simpler way but still with a single formula?
Thanks a lot for your next input!
In the mean time I did some simplification of my previous Monster formula and learned the ArrayFormula application in the process.
1st I tried to shorten the big blank cells intervals into ranges formulations to see if it still worked.
For example I changed:
AND(A1<>"",A2="",A3="",A4<>""),ROWS(A1:A4)-1,
into
AND(A1<>"",A2:A3="",A4<>""),ROWS(A1:A4)-1,
And it shortened my formula from this:
to this:
But then when pasting the new formula I got a #VALUE! error 'an array value could not be found'.
After further tests, I used the ArrayFormula and it worked by adapting the simple 'ranges' previously used to Arrays:
from this
AND(A1<>"",A2:A3="",A4<>""),ROWS(A1:A4)-1,
into this
AND(A1<>"",ArrayFormula(A2:A3=""),A4<>""),ROWS(A1:A4)-1,
With this final result:
=IFS(AND(A1="",A2=""),"",AND(A1="",A2<>""),"",AND(A1<>"",A2<>""),ROWS(A1),AND(A1<>"",A2="",A3<>""),ROWS(A1:A3)-1,AND(A1<>"",ArrayFormula(A2:A3=""),A4<>""),ROWS(A1:A4)-1,AND(A1<>"",ArrayFormula(A2:A4=""),A5<>""),ROWS(A1:A5)-1,AND(A1<>"",ArrayFormula(A2:A5=""),A6<>""),ROWS(A1:A6)-1,AND(A1<>"",ArrayFormula(A2:A6=""),A7<>""),ROWS(A1:A7)-1,AND(A1<>"",ArrayFormula(A2:A7=""),A8<>""),ROWS(A1:A8)-1,AND(A1<>"",ArrayFormula(A2:A8=""),A9<>""),ROWS(A1:A9)-1,AND(A1<>"",ArrayFormula(A2:A9=""),A10<>""),ROWS(A1:A10)-1,AND(A1<>"",ArrayFormula(A2:A10=""),A11<>""),ROWS(A1:A11)-1,AND(A1<>"",ArrayFormula(A2:A11=""),A12<>""),ROWS(A1:A12)-1,AND(A1<>"",ArrayFormula(A2:A12=""),A13<>""),ROWS(A1:A13)-1,AND(A1<>"",ArrayFormula(A2:A13=""),A14<>""),ROWS(A1:A14)-1,AND(A1<>"",ArrayFormula(A2:A14=""),A15<>""),ROWS(A1:A15)-1,AND(A1<>"",ArrayFormula(A2:A15=""),A16<>""),ROWS(A1:A16)-1,AND(A1<>"",ArrayFormula(A2:A16=""),A17<>""),ROWS(A1:A17)-1,AND(A1<>"",ArrayFormula(A2:A17=""),A18<>""),ROWS(A1:A18)-1,AND(A1<>"",ArrayFormula(A2:A18=""),A19<>""),ROWS(A1:A19)-1,AND(A1<>"",ArrayFormula(A2:A19=""),A20<>""),ROWS(A1:A20)-1,AND(A1<>"",ArrayFormula(A2:A20=""),A21<>""),ROWS(A1:A21)-1,AND(A1<>"",ArrayFormula(A2:A21=""),A22<>""),ROWS(A1:A22)-1,AND(A1<>"",ArrayFormula(A2:A22=""),A23<>""),ROWS(A1:A23)-1,AND(A1<>"",ArrayFormula(A2:A23=""),A24<>""),ROWS(A1:A24)-1,AND(A1<>"",ArrayFormula(A2:A24=""),A25<>""),ROWS(A1:A25)-1,AND(A1<>"",ArrayFormula(A2:A25=""),A26<>""),ROWS(A1:A26)-1,AND(A1<>"",ArrayFormula(A2:A26=""),A27<>""),ROWS(A1:A27)-1,AND(A1<>"",ArrayFormula(A2:A27=""),A28<>""),ROWS(A1:A28)-1,AND(A1<>"",ArrayFormula(A2:A28=""),A29<>""),ROWS(A1:A29)-1,AND(A1<>"",ArrayFormula(A2:A29=""),A30<>""),ROWS(A1:A30)-1,AND(A1<>"",ArrayFormula(A2:A30=""),A31<>""),ROWS(A1:A31)-1,AND(A1<>"",ArrayFormula(A2:A31=""),A32<>""),ROWS(A1:A32)-1,AND(A1<>"",ArrayFormula(A2:A32=""),A33<>""),ROWS(A1:A33)-1,AND(A1<>"",ArrayFormula(A2:A33=""),A34<>""),ROWS(A1:A34)-1,AND(A1<>"",ArrayFormula(A2:A34=""),A35<>""),ROWS(A1:A35)-1,AND(A1<>"",ArrayFormula(A2:A35=""),A36<>""),ROWS(A1:A36)-1,AND(A1<>"",ArrayFormula(A2:A36=""),A37<>""),ROWS(A1:A37)-1,AND(A1<>"",ArrayFormula(A2:A37=""),A38<>""),ROWS(A1:A38)-1,AND(A1<>"",ArrayFormula(A2:A38=""),A39<>""),ROWS(A1:A39)-1,AND(A1<>"",ArrayFormula(A2:A39=""),A40<>""),ROWS(A1:A40)-1,AND(A1<>"",ArrayFormula(A2:A40=""),A41<>""),ROWS(A1:A41)-1,AND(A1<>"",ArrayFormula(A2:A41=""),A42<>""),ROWS(A1:A42)-1,AND(A1<>"",ArrayFormula(A2:A42=""),A43<>""),ROWS(A1:A43)-1,AND(A1<>"",ArrayFormula(A2:A43=""),A44<>""),ROWS(A1:A44)-1,AND(A1<>"",ArrayFormula(A2:A44=""),A45<>""),ROWS(A1:A45)-1,AND(A1<>"",ArrayFormula(A2:A45=""),A46<>""),ROWS(A1:A46)-1,AND(A1<>"",ArrayFormula(A2:A46=""),A47<>""),ROWS(A1:A47)-1,AND(A1<>"",ArrayFormula(A2:A47=""),A48<>""),ROWS(A1:A48)-1, AND(A1<>"",ArrayFormula(A2:A48=""),A49<>""),ROWS(A1:A49)-1, AND(A1<>"",ArrayFormula(A2:A49=""),A50<>""),ROWS(A1:A50)-1)
New Sheet here

Follow formula patterns for some cells only

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)

Resources