Modifying a script

35 views
Skip to first unread message

Dr. AHMED Al-Wasity

unread,
Nov 14, 2024, 10:22:30 PMNov 14
to Google Apps Script Community
Hi 
In this script, I need to change the position of range cells (A1:A7) from sheet "Example1" to the new sheet "Menu" in the same google sheet. How the script will be after changing? 
Another query:
If I want to apply this script on the 30 columns individually for each column. It is not worthy to repeat it 30 times for each column. Is there an ideal or optimum way to apply this code for each of 30 columns individually starting from column D (Cell D18) to (Cell AG118)? 

function checksetvalue(){
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheetByName('EXAMPLE1');
var valueA1 = sheet.getRange('A7').getValue();
let shName = ss.getSheetName();
let cell = sheet.getActiveCell();
let col = cell.getColumn();
let row = cell.getRow();

if(shName === "EXAMPLE1" && valueA1 === true && col === 1 && row === 7 ) {
sheet.getRange('A8:A15').setValue('A');

//DEFINE MENU SHEET
//PART DROPDOWN - no need to keep installing the rule after the first time
/*
var partCell = sheet.getRange('A8:A15');
var partRange = sheet.getRange('A1:A6');
var partRule = SpreadsheetApp.newDataValidation().requireValueInRange(partRange).build();
partCell.setDataValidation(partRule);
*/

} else if( shName === "EXAMPLE1" && valueA1 === false && col === 1 && row === 7 ){
sheet.getRange('A8:A15').clearContent();
}
}
Reply all
Reply to author
Forward
0 new messages