Quantcast
Channel: Hot Weekly Questions - Web Applications Stack Exchange
Viewing all articles
Browse latest Browse all 9782

Run two scripts simultaneously on one google sheet

$
0
0

Good morning,

I'm very new to scripting and I have two scripts on my file that work fine independently (either one or the other) but I will need both scripts to run at the same time at all times . Here are my two scripts hoping you can help me get them working simultaneously.

Script 1:

/*** Creates a Date Stamp if a column is edited.*///CORE VARIABLES// The column you want to check if something is entered.var COLUMNTOCHECK = 2;// Where you want the date time stamp offset from the input location. [row, column]var DATETIMELOCATION = [0,4];// Sheet you are working onvar SHEETNAME = 'Work'function onEdit(e) {var ss = SpreadsheetApp.getActiveSpreadsheet();var sheet = ss.getActiveSheet();//checks that we're on the correct sheet.if( sheet.getSheetName() == SHEETNAME ) {var selectedCell = ss.getActiveCell();//checks the column to ensure it is on the one we want to cause the date to appear.if( selectedCell.getColumn() == COLUMNTOCHECK) {var dateTimeCell = selectedCell.offset(DATETIMELOCATION[0],DATETIMELOCATION[1]);dateTimeCell.setValue(new Date());}}}

Script 2

/*** Creates a Date Stamp if a column is edited.*///CORE VARIABLES// The column you want to check if something is entered.var COLUMNTOCHECK = 4;// Where you want the date time stamp offset from the input location. [row, column]var DATETIMELOCATION = [0,4];// Sheet you are working onvar SHEETNAME = 'Work'function onEdit(e) {var ss = SpreadsheetApp.getActiveSpreadsheet();var sheet = ss.getActiveSheet();//checks that we're on the correct sheet.if( sheet.getSheetName() == SHEETNAME ) {var selectedCell = ss.getActiveCell();//checks the column to ensure it is on the one we want to cause the date to appear.if( selectedCell.getColumn() == COLUMNTOCHECK) {var dateTimeCell = selectedCell.offset(DATETIMELOCATION[0],DATETIMELOCATION[1]);dateTimeCell.setValue(new Date());}}}

As you can see the two are similar but one is to enter the date of the day when a column is modified and the other is to enter the date of the day when another column is modified. I entrust you my file to be more clear.

https://docs.google.com/spreadsheets/d/1n3yOUo86zoArPVeecerl9Pfblq53gxTinfPAe6xIgRk/edit?usp=share_l...


Viewing all articles
Browse latest Browse all 9782

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>