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

onSelectionChange(e) - load the data from one sheet to another by clicking on a cell without doing any changes in the Cell

$
0
0

Good day, the task is by clicking on a certain day of the month I receive the schedule which is written in the another sheet of the same document. The problem is when I click of a date, eg, the 1st day of the month, I see that the day in the head of the schedule field is changed but the schedule itself is not loaded. I click of 2nd day, the date in the head of schedule is changed but the schedule is loaded like for the 1st day. I click on any day, the date in the head od schedule is changed to the right but the schedule data is loaded for the previously clicked day...I need to fix it.

  var    SelDate,            DayRow,            DayCol,            YearNM,            Year_Sheet,            Name_Cabs,            Schedule_In_Year_Sheet,            Schedule_Rec;    function onSelectionChange(e) {      const range = e.range;      var   column = range.getColumn(),            row = range.getRow();      if (row >= 7 && row <= 12 && column >= 2 && column <= 8){       // Cells of calendar        var ss = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Client_Records");        YearNM = SpreadsheetApp.getActiveSpreadsheet().getRange("C3").getValue();         DayCol = 1 + 7 * SpreadsheetApp.getActiveSpreadsheet().getRange("BJ18").getValue(); // calculating of the Column depending on the chosen date        SelDate = range.getCell(1, 1).getValue();      // the clicked day         SpreadsheetApp.getActiveSpreadsheet().getRange("J5").setValue(SelDate);  // Setting the clicked day in the head of the schedule( works well)        Year_Sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(YearNM); // choose the sheet with the required year        Schedule_In_Year_Sheet = Year_Sheet.getRange(4,DayCol+1,32,6); // choose the required cell range        Schedule_In_Year_Sheet.copyValuesToRange(ss,11,16,7,38); // copy from one sheet to another      } // ================>>>> end if    } // onSelectionChange

Viewing all articles
Browse latest Browse all 9782

Trending Articles



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