How can I link the value of a cell to a sheet? - google-apps-script

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.

Related

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

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.

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.

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.

Cell validation with dropdown

How to validate data in cells with dropdown for preventing enter same values in two neighbour cells?
Spreadsheet test link
For my experience it's impossible to enter custom =myFunction() in the cell with data validation.

Data validation dropdown list selected item auto update when source list changed

I have two sheets. One sheet where I define category of items. Like
Category
<big>
<small>
<cute>
In other sheet I have list of items, where I'm assigning prepared category via data validation dropdown list.
item1 <big>
item2 <small>
item3 <cute>
I created data validation using Data->validation and picked data range and list range.
But when I change to , the change doesn't populate into other sheet. It only shows warning, that cell contain invalid data.
It is possible to update (automatically or by some script) selected item in dropdown menu, when I change it's source data ?
this is more a Google Spreadsheet related question but when you change value of a category exemple to the change will not be populated to previously selected values, it is normal. It is the way spreadsheet and excel works.
The way to automate change is to build a script which will replace values. My favorite solution is more to use replace function (ctrl+H). It is built in spreadsheet :-)
Other solution there is an addon : link
Stéphane