Automatically Change Sheet Reference in formula - google-sheets

I have hundreds of sheets, with one master sheet, and I have this formula in my master sheet
=IF(COUNTIF(Sheet2!M$2:M$11,"No")>0, "Y", "N")&COUNTIF(Sheet2!M$2:M$4,"No")&COUNTIF(Sheet2!M$2:M$7,"No")&COUNTIF(Sheet2!M$2:M$11,"No")
which basically grabs the number of yes or nos in a column from the referenced sheet, in this case 'Sheet2', and returns Yes, if there are multiple NOs in the column, and the other arguments just return the count of NOs in the cell ranges.
I just want to drag down the formula in the column it is located in, and have the Sheet reference change from Sheet2 to Sheet3, Sheet4, and so on, but it simply copies it down the column. I've tried looking into it, got some hints with using INDIRECT but I'm returning errors left and right that I'm not sure if I'm on the right track.
EDIT: sample data: https://docs.google.com/spreadsheets/d/1jcbjUs4Ho0LlXF-Olu5NkEw4THqaA0nB5dduYKfx5S8/edit?usp=sharing

I have successfully used below formula to count "No's" using a sheet reference from a cell. Try it out:
=IF(COUNTIF(INDIRECT("Sheet" & A1 & "!" & "A:A");"No")>0;"Y";"N")
You can change the column range to suit your need - I just used column "A" in each sheet and cell "A1" with the sheet reference, in the above case A1 contained the number 2 referring to "Sheet2".

You can replace the Sheet2!M$2:M$11 with the following:
INDIRECT("Sheet"&ROW()-1&"!M$2:M$11")
You have of course to replace the M$2:M$11 with the respective range references.

Related

Google Sheets referencing another sheet every nth row

In Google Sheets, I want to grab the text value from a sheet and put it every three rows in a separate sheet. I want there to be blank spaces in the rows in between.
For example, say I have a list of names on a sheet called "Customer Info" In Column A. On a separate sheet, I am keeping track of interactions with customers, and that data takes 3 rows. Every third row, I want to grab the name of the next customer from my sheet "Customer Info" and put it in column A of my sheet "Transactions."
I've been trying to find a way to use something like ='Customer Info'!A(x), and use a formula to get the value of x. I thought some variation of MOD would work.
Say Sheet2 is like:
In Sheet3 cell A1 enter 1 and in A2 enter:
=IF(MOD(ROW(),3)=1,1+MAX($A$1:A1),"")
and copy downwards. In B1 enter:
if(A1="","",index(Sheet2!A:A,A1))
and copy downwards:
You can change the number of empty rows by changing the arguments to MOD().
try:
=INDEX(TRIM(FLATTEN(SPLIT(QUERY(INDIRECT("Customer Info!A2:A"&
COUNTA(A2:A)+ROW(A2)-1)&"♀ ♀ ♀",,9^9), "♀"))))

Count the Occurences of a text for the whole spreadsheet

I have a spreadsheet where in every column I have a list of names. They can repeat, and whats even worse - cells can contain some additional text (apart from the name).
What I want to do is count the occurrences of the name in the whole spreadsheet (only looking at the name, omitting the potential additional text). Is Possible?
I tried the formula =UNIQUE, but it does not work vertically (I'm working with Google Sheets)
Example of a document https://docs.google.com/spreadsheets/d/1STtJr0yisSeuv2w8_JVgQABAL5EDzI8aFmH8Vp2cOko/edit?usp=sharing
You can use Countif, Arrayformula, and Regexreplace to accomplish this task
Assuming you have the data range from A2:E12 and the prefilled unique names starting from A14
Formula:
=countif(ARRAYFORMULA(regexreplace($A$2:$E$12,".\(.*","")),A14)
Copy the formula until the last row
Hope it helps!
I'm sure that others will provide a much more elegant solution but this takes the data as presented in the spreadsheet and can be implemented in just a few minutes.
Paste this formula in Cell F3
=FILTER({A3:A13;B3:B6;C3:C5;D3:D5;E3:E5;A18:A21;B18:B20;C18:C20;D18:D20;E18:E19}, LEN({A3:A13;B3:B6;C3:C5;D3:D5;E3:E5;A18:A21;B18:B20;C18:C20;D18:D20;E18:E19}))
This creates a single column list compiled from the various smaller lists.
Highlight the range of names created in Column F (based on the test data = F3:F41), click Copy,
Highlight cell G3, click Paste special (Paste Values only) - this converts the formula to a list for entries.
Paste this formula in Cell H3 - this removes any data in brackets
=left(G3,iferror(search(" (",G3)-1,len(G3)))
Copy the formula down as many rows as there is data in Column G
Paste this formula in cell I3 - this lists the unique names
=unique(H3:H41)
Paste this formula in cell J3 and copy down as many rows as there is data in Column I - this counts the number of instances of each unique name in the master list.
=COUNTIF(H:H, I3)

Google Spreadsheets: Formula to "interleave" or "zipper" multiple arrays

Tried searching and checking Google documentation but I am still having issues getting the results that I want for this problem.
I'm needing to split several comma-separated lists of items and recombine them so that first items in each list is combined, followed by the second item, etc.
To ask with an illustration, if I have a cell with the following
Paul, John, George, Ringo
and another cell with the following
McCartney, Lennon, Harrison, Starr
How do I use one function to produce this in a cell?
Paul McCartney, John Lennon, George Harrison, Ringo Starr
Here you go, you will need to copy to every row - but assuming your data is in columns A and B it will work across a dynamic number of items:
=ARRAYFORMULA(join(",",split(A1,",")&" "&split(B1,",")))
See image example below, in row one i used the data you showed up top, and in row two i reversed the column data just to show as an example:
If you paste the first word CSV to Sheet1 and the second word CSV to Sheet2 then you could put the following into sheet3
In Cell A1:
=Sheet1!A1&" "&Sheet2!A1
This is saying take the value in sheet1 A1 and then a space " " then the value in sheet2 A1
You could also do this with the concatenate function:
=CONCATENATE(Sheet1!A1," ",Sheet2!A1)
Then just copy the formula to suit.

Autofill data until next value is reached (but miss out one row each time)

I have a student attendance data sheet in which I need each student's name to appear in Column A, but only where the row for that student contains a subject. As you can see, I'm nearly there. In cell A4 I typed:
=B3
and in cell A5 I typed:
=IF(B4="",A4,B4)
...then just autofilled down from there. However, cells A17 and A31 (where a new student name appears on Column B) are messing up a formula I have on another sheet that references Column A on this sheet. Therefore, I'd like to leave these particular cells blank if possible, but I'm not sure how to achieve this.
I duplicated the sheet in your shared spreadsheet and entered in cell A3 this formula:
=ArrayFormula(if(isblank(C3:C),,if(row(C3:C) <= max(row(C3:C)),vlookup(row(C3:C),filter({row(C3:C),B3:B},len(B3:B)),2),)))
that seems to deliver the expected output.
See if that works for you ?
I made another copy and entered this formula into A5: =IF(B5="", IF(B4="",A4,B4), "")

Google spreadsheets: conditional formatting with custom formula based on values from different sheet

I have a google spreadsheet with two sheets. On the first sheet, the items are listed in column A, and their types are in column B.
On the second sheet, I reference to the first sheet's column A with the formula: =UNIQUE(Sheet1!A:A).
Then I want to color the items in the 2nd sheet based on the item type (1st sheet's column B*). I try to add conditional formatting using the formula =Sheet1!$B:$B="Type1", but when I try to save rules, it says the formula is invalid.
What would be the correct formula for this case?
You cannot reference cells directly in the conditional format formula. Also, I do not think that formula would work.
First, you need the VLOOKUP function to get the object's type.
Here's an example of using this function. The difference would be that the corresponding data in the first parameter would be preceded by the sheet name in your case.
See this image:
As you can see, VLOOKUP searchs for the item from D in the matrix A2:B4, and then returns the corresponding value (the value in the same row) in the second column of the matrix, which is column B.
So if you to apply this formula to conditional formatting, you would have:
=VLOOKUP($D$2:$D;$A$2:$B$4;2)="Dragon"
The first parameter of VLOOKUP has to be a range, and I started it from D2 so it would not match the header. In your case, it would become:
=VLOOKUP($D$2:$D;Sheet1!$A$2:$B$4;2)="Dragon"
But as you cannot use references directly, you need to use the INDIRECT function. It receives a cell range as a string and returns a reference to that range. It's the same as using references directly, but in this case you add an extra step (go figure). So the formula finally becomes:
=VLOOKUP($D:$D;INDIRECT("$A$2:$B$4");2)="Dragon"
You can choose any range to apply the format if you are using the new version of Spreadsheets. You could, for example, color the entire row or just a single cell.

Resources