How to loop over all sheets of a file in Google sheets? - google-sheets

I'm using Google sheets for storing some simple text. In a column (F) I have all names of sheets and I'm using the following to count occurrences of a certain string "aaa" in column C in all sheets:
SUMPRODUCT(COUNTIF(INDIRECT("'"&F3:F11&"'!C3:C200"),"*aaa*"))
It returns only occurrences in the first sheet. Any idea what is wrong?

Related

Column to row formula in Sheets [duplicate]

The Google Sheets formula below is located in column A1 of my Google Sheet. This formula creates data in column A & B. I need to transpose this data into 1 row
=GOOGLEFINANCE(A2,"price",TODAY()-30,TODAY())
=TRANSPOSE(GOOGLEFINANCE(A2,"price",TODAY()-30,TODAY()))
The transpose formula successfully transposes the data in the 2 columns to 2 rows, as it should. My question is, will there be a way to transpose two columns of data into 1 single row - I have searched around for a solution for Google Sheets without any Luck.
you can use famous "double query smush" like:
=QUERY(TRANSPOSE(QUERY(TRANSPOSE(GOOGLEFINANCE(A2, "price", TODAY()-30, TODAY())),,999^99)),,999^99)

Using SumProduct With Array Formula in Google Sheet

I have a problem to use sumproduct with array formula in Google Sheet which seems workable in Excel. The formula returns only 1st array value (E8*F8) which what I have to do is to get total sales price from everyday.
Below is the formula I used:
=SUMPRODUCT(ARRAYFORMULA(INDEX(E8:J8,,column(A1:C1)*2-1)),ARRAYFORMULA(INDEX(E8:J8,,column(A1:C1)*2)))
Below is the table view:
My Spread Sheet Link
Try this formula
=SUMPRODUCT(ARRAYFORMULA(FILTER(E8:J8, ISEVEN(COLUMN(E8:J8)))), ARRAYFORMULA(FILTER(E8:J8, ISODD(COLUMN(E8:J8)))))
Or even simpler
=SUMPRODUCT({E8,G8,I8}, {F8,H8,J8})

Handle array size in Excel or Google Sheets

To create a 1x3 array in Excel or Google Sheets I can do:
={1,2, 3}
For example:
How would I create a multi-dimensional array, for example, a 3x3 array in Excel or Google Sheets?
Comma for columns, semicolon for rows (but it does depend on you language settings)
={1,2,3;4,5,6;7,8,9}
In Google Sheets and Excel, the union operator is ; so you can do:
'={1,2,3; 4,5,6; 7,8,9}
In Google Sheets you can use the following formula
=SEQUENCE(3,3)
Functions used:
SEQUENCE

Google sheets import from multiple sheets giving error

I have created a master sheet which imports the data for the other sheets which are representing the dates of the month. In the sheet the master sheet cell A2 has the formula to import from the other sheets which the google sheet
Google Spread Sheet.
The issue I am facing is that if in the formula I change the sheet 10 range from A2:CH to A2:CO it gives an error
Error
In ARRAY_LITERAL, an Array Literal was missing values for one or more rows.
I am not being able to find the problem as this is not a permissions issue and neither does sheet 10 have any data in this case.
full code is below:
=UNIQUE(query({'1'!A2:CO;'2'!A2:CO;'3'!A2:CO;'4'!A2:CO;'5'!A2:CO;'6'!A2:CO;'7'!A2:CO;'8'!A2:CO;'9'!A2:CO;'10'!A2:CO;'11'!A2:CO;'12'!A2:CO;'13'!A2:CO;'14'!A2:CO;'15'!A2:CO;'16'!A2:CO;'17'!A2:CO;'18'!A2:CO;'19'!A2:CO;'20'!A2:CO;'21'!A2:CO;'22'!A2:CO;'23'!A2:CO;'24'!A2:CO;'25'!A2:CO;'26'!A2:CO;'27'!A1:CO;'28'!A2:CO;'29'!A2:CO;'30'!A2:CO;'31'!A2:CO},"select * where Col1 is not null"))

How to convert Excel formula to Google Sheets?

This code calculates a sum of string lengths in the range H1:V5 using G as a row index and C as a column index. It works perfectly in Excel:
{=SUMPRODUCT(LEN(INDEX(H1:V5,N(IF({1},ROW(G2:G5))),N(IF({1},C2:C5+1))))*ISNUMBER(G2:G5))}
But when I try it in Google Sheets it doesn't work although Google Sheets recognizes all commands. Is it possible to convert my formula to Google Sheets? Or maybe there is some workaround to get the same result there?
Open with Google Sheets returns incorrect result:
=ARRAY_CONSTRAIN(ARRAYFORMULA(SUMPRODUCT(LEN(INDEX(H1:V5,N(IF({1},ROW(G2:G5))),N(IF({1},C2:C5+1))))*ISNUMBER(G2:G5))), 1, 1)
Unfortunately the construct index...n(if({1}... is peculiar to Excel.
The vlookup function in Google sheets is very versatile and you can use that instead:
=SUMPRODUCT(len(vlookup(row(H1:K5),{row(H1:K5),H1:K5},C1:C5+2,false))*isnumber(G1:G5))

Resources