Search Name in 2 cells and return the value in third cell if the name matches - google-apps-script

I would like to create a formula in my Google Sheet where I put the name of any person in one cell then the data related to that person/'s should populate against that cell (in a single cell only)
I'm attaching an image for reference
Request to share the possible solution for the above problem.
Thank you
I tried Vlookup but it is not showing up all the details and not working as well.
=TEXTJOIN(", ",TRUE,IF($E$2=$A$2:$A$12,$B$2:$B$12,""))
I tried the above Formula but it didn't work.

VLOOKUP just returns the first occurrence, altought you can use TEXTJOIN and FILTER to make that. Take a look at that:
=TEXTJOIN(", ";TRUE;FILTER(B2:B12;E2=A2:A12))
You can read more about that functions here:
https://support.google.com/docs/answer/3093197?hl=en
https://support.google.com/docs/answer/7013992?hl=en

Related

Copy Adjacent Cells alongside Duplicate Cells

I have a very large Google Sheet spreadsheet that I need help with.
I have a long list of Network Switches that are very often repeated that I am trying to automatically copy the associated SKU into a separate adjacent cell.
My goal was, once the SKU is added the first time, whenever the same switch is added again, it will autopopulate with the same SKU.
For instance, C2461:C2463 are repeated, and once K2461 is populated, would like K2462 & K2463 to follow suit.
Any help would be greatly appreciated!
You can try this formula on Column L (col L will serve as a helper column):
=iferror(arrayformula(VLOOKUP(C2:C,C2:K,9,False)),"")
For now I can't seem to fit the formula without the use of a helper column (so I created a separate sheet for now that will serve as a database for the VLOOKUP formula) but this should get you started.
Sample using a helper spreadsheet (Database):
=iferror(arrayformula(VLOOKUP(Database!A2:A,Database!A2:B,2,False)),"")
Output:

Comparing two sentences and merge while removing duplicates

I plan on creating a remarks column within my sheet, and I want it to be such that whenever I update one side or the other, it will merge the remark and remove any duplicates within it.
Would appreciate if anyone has any inputs on this.
Example:
Remarks in the column of one google sheet:
-Friendly -Fun
Remarks in the other column of another google sheet :
-Friendly -Cheerful
So my google script will get the string in both columns, I would like to make the end result of the string to be :
-Friendly -Cheerful -Fun
Can you try like this to what I understand and see attached image as will
=Unique(Transpose(Split(TEXTJOIN(" ",True,B2,D2),"-",True)),False,False)

How to send cell data from one google spreadsheet to another, but only if the cell colour is correct?

I have a spreadsheet with cells coloured in two different colours. I know I can send all the cell data from one google spreadsheet to another using IMPORTRANGE function. However, I only want to send the cell data if it satisfies a specified cell colour.
For example, if spreadsheet A has 10x10 data with various colours, then spreadsheet B should contain all the data from cells in spreadsheet A that are either red or green (and also transfer the cell colours). All other cells with different colours from spreadsheet A should be transferred to spreadsheet B as blank colourless cells. The resulting spreadsheet should still contain 10x10 cell data, but with only red, green and blank cells.
I know it should be possible to write a function for this, but I have never written any custom functions before and have no Javascript experience. Any kind of help would be appreciated. Perhaps also the QUERY function could be of use?
Thanks in advance!
You should check about Google Apps Script. It gives you a set of tools that will allow you to create a script for doing what you want.
Custom Functions will help you to create a function that lets you get the values from your sheet and then set the conditions you are requiring.
The Class SpreadsheetApp has the tools for handling all data in your sheets. Check for example the method getBackgrounds(), which gets the color in a range of cells.
This another post, it is a little similar in some aspects to what you want to do.
It's best practice to create an additional column which stores the information regarding as to which condition (color) is applied 5o the particular row. Once you have done that, you can easily transport a table from one Spreadsheet to another using the QUERY formula within the IMPORTRANGE.
Image column a is the name of a city.
Imagine column b holds the information regarding the condition (color). This is an helper column.
Now we have col1 = New York City, col2= green
Then you could enter this into the new sheet.
QUERY( IMPORTRANGE(URL, range), "SELECT col1 WHERE col2="green" OR col2="yellow" OR col2="red")
Here is a great tutorial series I like to use.
https://youtu.be/_N5zhAipVn0

Google Sheets formula that includes values from another cell

In Google Sheets, I have a formula in a cell that connects to an API with a script and spits out the JSON results. For example, I can connect to the Youtube API with a formula that looks like this,
=ImportJSON("https://www.googleapis.com/youtube/v3/videos?id=mv-cj6mBkPk&key=API KEY&fields=items(id,snippet(channelId,title,categoryId),statistics)&part=snippet,statistics")
I'd like to make part of that formula get it's value from a separate cell. For example, the video ID above (mv-cj6mBkPk), rather than have it typed in the above formula, I'd like to pull in the value from a cell (i.e. B1). Then I can create multiple versions of this formula with other video IDs (i.e B2, B3, etc.)
I've tried combining various parts of the formula through CONCATENATE-ing a few cells, but that doesn't seem to 'RUN' the formula, it just shows it.
My skills aren't so advanced in this area, so any help would be great. Thanks!!
It is not obvious what your problem is exactly, or where you got the code for the ImportJSON() function (as this is not a built-in function),
but a variation of the below SHOULD work - if it does not, then post what error you are getting (exactly).
Also, I presume you have substituted "API KEY" for the actual key... I have used API_KEY, so that the formula does not get broken across multiple lines here.
A1 : mv-cj6mBkPk
A2 : =ImportJSON("https://www.googleapis.com/youtube/v3/videos?id="&A1&"&key=API_KEY&fields=items(id,snippet(channelId,title,categoryId),statistics)&part=snippet,statistics")

Referencing cell on other tab in formula

How to reference the same (row,column) on the different tab in the same google spreadsheet document?
So, I want to do something like this:
=SOME_FORMULA('First tab'!(ADDRESS(ROW(),COLUMN()))). This doesn't work.
If the formula isn't apsolutly referenced, entries of Google Forms questionnaire change the reference and mess up the formula. (the formula that looked at row number 5 after insert looks at row number 6) I can't use apsolute referencing ($A$1) because I have to enter it manually.
Can I change the reference on multiple cells? (for one I can use cmd + f4)
I had that annoying reference problem too. If I understand correctly you are trying to get the information on some cells, but every time someone sends information to the spreadsheet by filling up a Form, that reference moves down a row.
The best solution I came up with was to create a new SpreadSheet and import all the information with this:
=importrange("spreadsheet-key","Form Responses!A1:B2107")
That function updates the info in realtime, so you can do all the processing on the new spreadsheet.
Hope this helps.
Do not quite understand what you need. Need to reference a cell in another sheet given coordinates on the current cell where it is located?
If so, the following formula can be useful:
=INDIRECT("First tab!"&ADDRESS(ROW(), COLUMN()))