IAmMoonie

r/sheets | deleteCell

Nov 19th, 2022 (edited)
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JavaScript 1.11 KB | Source Code | 0 0
  1. /**
  2.  * CONFIGURATION SECTION :=============================================================================
  3.  * Edit the variables here to match the information in your sheet
  4.  */
  5.  
  6.  INPUT_SHEET = "INPUT";
  7.  OUTPUT_SHEET = "OUTPUT";
  8.  DATE_TO_MATCH = "1-Jan-2022";
  9.  
  10.  /**
  11.   * END OF CONFIGURATION SECTION :======================================================================
  12.   * Do not edit the code under this point
  13.   */
  14.  
  15.  /**
  16.   * It gets the values from the input sheet, and then compares them to the date to match. If the date
  17.   * matches, it clears the content.
  18.   */
  19.  function deleteCell() {
  20.    const ss = SpreadsheetApp.getActiveSpreadsheet();
  21.    const sheet1 = ss.getSheetByName(INPUT_SHEET);
  22.    const sheet2 = ss.getSheetByName(OUTPUT_SHEET);
  23.    let inputValue = sheet1.getRange("H4:H15").getValues();
  24.    const outputValue = sheet2.getRange("H4:H100").getValues();
  25.    const dateToMatch = new Date(DATE_TO_MATCH).toDateString();
  26.    inputValue.forEach((value) => {
  27.      value = new Date(value).toDateString();
  28.      if (value === dateToMatch) {
  29.        value.clearContent;
  30.      }
  31.    });
  32.    debugger;
  33.  }
Advertisement
Add Comment
Please, Sign In to add comment