I am currently trying to add a button to make a towns profit added to a sheet per session I looked on an older post and I am trying to make the button for it the function I'm using doesn't seem to be working
I get an error message:
Script function function increment() { SpreadsheetApp.getActiveSheet().getRange('F1').setValue(SpreadsheetApp.getActiveSheet().getRange('F1').getValue() + 1); } could not be found
Error screenshot
Any advice is appreciated
Answer:
Put your function in Google Apps Script, accessed in menu Tools -> Script Editor, save it, then assign the function name to the button.
The first time you click the button you will have to authorize your sheet.
Related
How do I set a new default tab to be a specific spreadsheet that I made with formulas, etc.., so that every time I click a new tab, it opens up this specific spreadsheet, instead of a blank Google sheet page?
Is there a VBA code?
grab the sheet tab and move it to the front:
_______________________________________________________________
if this is a question about setting up a template as the default page for every newly created spreadsheet - that's not possible. templates are available for individual selection under this button:
_______________________________________________________________
to actually "clone" the sheet you will need to use a script. you can try something like:
function cloneGoogleSheet() {
var name = "labnol";
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheetByName('Template').copyTo(ss);
/* Before cloning the sheet, delete any previous copy */
var old = ss.getSheetByName(name);
if (old) ss.deleteSheet(old); // or old.setName(new Name);
SpreadsheetApp.flush(); // Utilities.sleep(2000);
sheet.setName(company);
/* Make the new sheet active */
ss.setActiveSheet(sheet);
}
From my ad hoc trying, Google Sheet seems to determine the default Tab by the creation time. My simple solution is to copy/delete any Tab that is older than the desired new default.
For example, we have a Tab "New Default" that we want to set to the new default. Assume there are only a small number of Tabs (3 Tabs) created before the "New Default" Tab, and all other Tabs were created after the "New Default" tab.
(1) Create three new empty tabs.
(2) Copy over the three tabs created before the "new default" Tab,
so that we do not lose them. Then delete these three tabs.
Now the "New Default" becomes the default tab when open the link to the spreadsheet.
Note:
Of course, this approach has limitations and may need a script to do the copy/delete. Or even better if Google Sheet team adds support to set default though GUI directly.
Alternatives:
Before I came up with this low-tech solution, I also tried using a Google App Script .setActiveSheet("New Default") method on start. It works for the jumping; however, when people comment in the "New Default" tab, I got a notification in email. When clicking the comment, it jumps to the top of the default tab, which is annoying since it loses focus to the comments text.
Hello, I am making an initiative table for D&D using google sheets.
At the moment I have a Mainsheet in which myself (the DM) can edit and change, and Playersheet that has the data the players need using IMPORTRANGE.
I am attempting to write a script that will automatically hide all empty "initiative" cells in PlayerSheet .
I have successfully coded this script, however I would like it to trigger any time I edit the MainSheet.
Because all the date in the sheet comes from using IMPORTRANGE I am not able to use the on edit trigger, as the PlayerSheet is never edited.
Is it possible to have the script located in PlayerSheet run whenever I edit MainSheet?
On top of that would it be possible to have the script only run when I edit data in the F column?
To run the script whenever you edit your spreadsheet, you can create a fonction on edit.
function onEdit(e){
var range = e.range;
//here you can check if the column if F or not and run your code.
}
Tu change the values of another spreadsheet, when selecting the spreadsheet you want to do the actions on, instead of selecting the active one, you can edit one with the url. Something like :
var doc = SpreadsheetApp.openByUrl("paste the url here");
var sheet = doc.getSheetByName("Name of the sheet");
etc...
And then do the modifications you need to do on the players spreadsheet.
I'm very new to scripting and really need some help getting started.
Basically I'm trying to develop a simple script to show a warning message when a certain value in a cell has been selected from a drop down list.
When the option 'Behind' has been selected I just want a simple popup window or something to say 'Review is needed'.
I've explored 'toast' but I'm not sure how I'd get the script to run based on the value.
Any help would be much appreciated, I'm going bald :(
Emma
You can also achieve this kind of behavior without writing your own script. See Data validation.
Select the cells for which you want this to apply
Click on Data -> Data Validation in the menu
Set your criteria for allowed values
On invalid data, select either Show Warning or Reject Input (the latter will reject the input and show a toast)
Put a checkbox in Show validation help text to add a custom warning text
I'm creating a script that logs a user into a site. Everything works but for some reason when the user clicks on the link to go to their profile the link opens in a new window and at first redirects before going to the correct page.
For example:
The correct link is: https://sites.google.com/site/examplelehan/Jan_Moolman but the moment the link is clicked the link that is actually executed in the address bar changes to: http://www.google.com/url?q=https%3A%2F%2Fsites.google.com%2Fsite%2Fexamplelehan%2FJan_Moolman&sa=D&usd=2&usg=AFQjCNFXLLswDh2AWCBpYi54jNXxpZVGPQ
So it seems as if www.google.co.za is being pre-pended to the url. I've seen other posts as well but none of them seem to be offering working solutions. A few posts have said that this occurs when the link is created without the http:// prefix but I've tested that and the same problem occurs.
I've also tried using .createHTML in order to create the link but for some reason the link doesn't show, any other HTML I use seems to work so I guess that's why Google created the Anchor function.
Thank you in advance for your help.
In this issue tracker comment Eric Koleda suggested a workaround using UrlShortener Services . I tested it with your link (http://goo.gl/HRPfU) and it seems to be a working solution.
EDIT : to answer your comment, here is a working example :
function test(){
var shorturl=short('https://sites.google.com/site/examplelehan/Jan_Moolman');
Logger.log(shorturl);
}
//
function short(longurl){
var toShorten = UrlShortener.newUrl().setLongUrl(longurl);
var short = UrlShortener.Url.insert(toShorten).getId();
return short
}
note that this API has to be activated before it can be used (see docs)
I'm trying to figure out how to use the iPhoneKeyboard function in Unity3D. I want to be able to run a function when a user hits the button "OK" in the keyboard. I just simply can't figure this out.
The second question in this matter is how I can change the "OK" to "Search"?
check out IPhoneKeyboard.Open in the Reference.. there is one example
After you can process the user input using the IPhoneKeybard.done attribute (also one example)