Zac123
asked on
onOpen
hi, i wrote this little bit of code myself. i think if you look at it you'll see what i'm trying to achieve...
it runs through the script ok without error but nothing happens. i have setup the triggers as well.
onOpen, set value of I1 to No
function onOpen2() {
var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
var cell = sheet.getRange ("I1");
cell.setValue("No");
}
it runs through the script ok without error but nothing happens. i have setup the triggers as well.
ASKER
Hi, thanks. i'm using google sheets, does that matter?
Is the code definitely running?
ASKER
changed my code to
but it doesnt work. no error.
function onOpen2() {
var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
Range = ("I1").value = "No";
}
but it doesnt work. no error.
ASKER
yep i have set the triggers up so i think it should be running
Yes, using Google Sheets vs MS Excel does matter. They would use different formulas. i don't know enough about Google Sheets to give a better example, but these might help:
Cell Refences
Google Functions List
Cell Refences
Google Functions List
Use :
or :
var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
var range = sheet.getRange("I1");
range.setValue("No");
or :
SpreadsheetApp.getActiveSpreadsheet().getActiveSheet().getRange("I1").setValue("No");
so did it worked?
If you are not using Excel, but instead are using Google Sheets, you should remove the Excel tag.
ASKER
hiya,
with this code:
it works but it places it on whatever tab is first. could i specify a tab called 'dataEntry' please?
with this code:
function onOpen2() {
var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
var range = sheet.getRange("I1");
range.setValue("No");
}
it works but it places it on whatever tab is first. could i specify a tab called 'dataEntry' please?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
your code is obviously fine but i think it is not working because i already use a dropdown in that col. would this stop the onOpen from working?
I don't see any other reason
ASKER
thanks so much for your extended help. i made a very silly mistake.... your code works perfectly but i was telling you I1 and should have been I2. very sorry about this...
var ss = SpreadsheetApp.getActiveSp readsheet( );
var sheet = ss.getSheetByName("dataEnt ry");
var range = sheet.getRange("I2");
range.setValue("No");
var ss = SpreadsheetApp.getActiveSp
var sheet = ss.getSheetByName("dataEnt
var range = sheet.getRange("I2");
range.setValue("No");
Open in new window
toOpen in new window
?I find it easier to use VBA with excel than trying to use any other language.