Google Sheets - Change data in a sheet depending on what cell is clicked - google-apps-script

I have a "Main page" in my spreadsheet that allows you to search for chemicals and returns some information on any match found within the source data. I want each result to have a link that the user can click that will open up a sheet with some more detailed information on the particular chemical clicked. Is this possible?
Example - clicking F5 would link to another sheet that would fill in cell A1 with "Carbon Monoxide" but clicking F6 would instead fill in the cell with "Nickel Carbonate"

You should first make a list of all search items along with the links of the desired page, then in column G use vlookup to get the link based on the name from column C.
Now in column F use the Hyperlink function to generate a clickable link say
=HYPERLINK(G5,"See More")
Can use arrayformula for entire range.

Related

G Sheets Table of Contents Script

For Google sheet workbooks that have several sheets, I create a Table of Contents sheet that lists all of the sheets in the workbook to increase ease of use for users.
I have looked for an add-on, macro, or script that can speed up the process. No dice. Any ideas for how to automate the process of creating a new sheet that lists the names of all of the other sheets (One sheet name per cell) and then automatically links the cell to that sheet?
Just to expound, this is a great solution except it will not update when you add new tabs or rename/ reorder current tabs. The only solution I could find is to create a simple checkbox trigger.
First I added a checkbox on my Table of Contents tab page. Then I added the script above except, instead of SHEETLIST() in line one I added my checkbox's cell number - for example, SHEETLIST(B3).
Then, I put the formula; in which populates the two columns of data - Name & #GID. In another cell (with plenty of room to list all the tabs) I put the top =ARRAYFORMULA... (not the one with the VLOOKUP) but, again, instead of empty parenthesis after SHEETLIST() I input my checkbox's cell number in both places, like below:
=ARRAYFORMULA(HYPERLINK("#gid="&
QUERY(INDEX(SHEETLIST(B3);;2); "offset 1");
QUERY(INDEX(SHEETLIST(B3);;1); "offset 1")))
I then hid the columns with the NAME & #GID data so you can only see the hyperlinked Table of Contents.
Now, whenever I update my tabs I just click the checkbox and it forces everything to reload. Not completely automatic/ dynamic but the best solution I could find.

Script for copy over values only via button

In this sheet, I have some boxes which calculate information, (Columns K:BO)
I have drawn a button next to each box (ADD LINE)
I need a script attached to the button that will transfer only the information in the coloured cells from each box across to a "Collection Box' in Column (DC:DK)
Each box calculates differently and sometimes I may not need information from all boxes at once hence a button for each one.
The goal is to be able to organise the information so I'm able to copy and paste the information the from the Collection Box (DC:DK) as needed so I don't have to painstakingly extract the information bit by bit
For Example...
I have made a box in Columns CF:CN which only mirrors the information I require.
Problem is when I'm not using certain rows the information gets hard to read because of the cluster,
As you might see I've tried to overcome this with basic cell formatting to highlight the information that I'm using at the time
Also the cells in columns CF:CN has cell references applied so I can change the output in columns as needed.
This would be ideal for me to keep.
I'm not sure on the boundaries of the script, but is there a way that when the information is copied to the collection box so it can still utilize the cell reference to change the information without me having to re-enter?
Here is Sheet
Information is in Update Price Tab
https://docs.google.com/spreadsheets/d/1UdYCqgKEGJeh4KajxQWfTCi-JRpQgGM7435Q_VwHIH8/edit?usp=sharing
a script for copy-over values only is:
function moveValuesOnly() { var ss = SpreadsheetApp.getActiveSpreadsheet();
var source = ss.getRange('Sheet1!A1');
source.copyTo(ss.getRange('Sheet1!B1'), {contentsOnly: true}); }
this particular one will copy values from Sheet1!A1 to Sheet1!B1 if attached to a button

Hyperlink to a cell/row in the leftmost sheet of Google spreadsheet, even if sheets are moved?

I have a Google Sheets spreadsheet where I keep notes on monthly tasks, so each sheet represents one month. I always move the current month's sheet so that it's first in the spreadsheet. I want to be able to send my coworkers a hyperlink that always links to a cell or row the first/leftmost sheet, no matter what sheet that is.
For example, if I have a cell labeled "Customer 3," then I want the hyperlink to go to the "Customer 3" cell on the first/leftmost sheet in my spreadsheet regardless of whether it's the January, February, or March sheet. And when I create a new sheet - April - and move it to the leftmost position, I want the link to go to the "Customer 3" cell/row on the new April sheet.
I know how to link to a specific cell, to a specific sheet, and to a specific cell within a specific sheet. But I don't want to have to recreate the hyperlinks every month. Is there a way to accomplish this, either natively or with a Google Apps script?
Thanks.
If you want to make reference to the first sheet, then use .getSheets[0]
It will always reference the first sheet, regardless of its name.
function firstSheet (){
var firstSheet = SpreadsheetApp.getActive().getSheets()[0];
return firstSheet;
}
EDIT: you can get the ID of the first sheet dynamically by:
var firstSheet = SpreadsheetApp.getActive().getSheets()[0].getSheetId()
The hyperlink is composed of several 'elements' so to call them. You get the spreadsheet ID, and then you get the sheet specifics as an "edit#gid=______"
I've made some tests, and I believe that as long as you only use the spreadsheet ID, it will always by default link to the first sheet.
You can do that directly through the hyperlink, only writing the link until just before the "edit#gid=_____" part, but then you would need google apps script to find the cell automatically, so I would suggest doing it all through the script to make it more simple and organized.
When you write the script and link to the spreadsheet, it will always give you the first spreadsheet. Anyways, maybe it would be helpful to see some of your script to help you out more directly.

Unable to extract link text from tooltip in Google Spreadsheet

I'm optimistic this question has already been answered. But if not, I'm hopeful that one of you JavaScript and Google Script experts can lend some assistance.
Steps to Reproduce
Go to www.nhl.com/stats/player
Copy the top few rows in the table (see screenshot #1)
Paste the contents into a new Google Spreadsheet
Click on the name of a player in the "Player" column (see screenshot #2)
Notice that the name itself is shown in the formula bar while the tooltip has a link to the player's profile on nhl.com
What I Want to Happen
I'd like to extract the link content that's shown in the toolip. (In screenshot #2 this is referring to the https://www.nh...layer/8471215 text.)
What Actually Happens
Nothing really. There's no way to see the tooltip content in the formula bar and, as far as I can tell, there's no function (e.g. hyperlink) to extract the tooltip content.
Screenshots
Screenshot #1
Screenshot #2
Other Notes
I'm comfortable coding in JavaScript, but I have minimal experience in the script editor.
In addition to what Anton has said, Apps Script has only support for A1 Notation and R1C1 formulas for now:
getFormulas()
Returns the formula (A1 notation) for the top-left cell of the range,
or an empty string if the cell is empty or doesn't contain a formula.
getFormulaR1C1()
Returns the formula (R1C1 notation) for a given cell, or null if none.

How can I link the value of a cell to a sheet?

I'm having some trouble with this exercise, I have a data validation list in a cell (A,B & C) and also 3 sheets with those names. What I'm trying to do is to link the value of that cell so I can be re-directed to the Sheet that has it's name in the cell
What you are trying to do is impossible - data validation items cannot be linked to a browser action.
One possible workaround would be to create a range with each cell containing a hyperlink formula with the name and url of the sheets you want to link. Then you would create a data validation based on this range and users could click on the link after selecting from the dropdown.