Script for auto-hidden rows (help)

289 views
Skip to first unread message

Роман Андриянов

unread,
Nov 8, 2021, 5:59:53 AM11/8/21
to Google Apps Script Community
Hi everyone!)
There is a table where the date is entered into the values ​​of the first column. It is necessary to hide rows of past dates, relative to the current date.

I would be grateful for your help)00

Tanaike

unread,
Nov 9, 2021, 6:59:16 AM11/9/21
to Google Apps Script Community
I have to apologize for my poor English skill. Unfortunately, I cannot imagine your Spreadsheet from `There is a table where the date is entered into the values ​​of the first column. It is necessary to hide rows of past dates, relative to the current date.`. In order to correctly understand your question, can you provide your sample Spreadsheet?

Роман Андриянов

unread,
Nov 9, 2021, 10:01:45 AM11/9/21
to Google Apps Script Community
You understood everything correctly)

Here Is example ;)

вторник, 9 ноября 2021 г. в 14:59:16 UTC+3, Tanaike:

Роман Андриянов

unread,
Nov 9, 2021, 10:01:51 AM11/9/21
to Google Apps Script Community
You got it right ;)))
Example:
https://docs.google.com/spreadsheets/d/12bkCXawXTDRRIfcAvSy1DgxdZScvy-_n3W4VSsPCiXk/edit?usp=sharing

вторник, 9 ноября 2021 г. в 14:59:16 UTC+3, Tanaike:
I have to apologize for my poor English skill. Unfortunately, I cannot imagine your Spreadsheet from `There is a table where the date is entered into the values ​​of the first column. It is necessary to hide rows of past dates, relative to the current date.`. In order to correctly understand your question, can you provide your sample Spreadsheet?

Tanaike

unread,
Nov 9, 2021, 9:32:18 PM11/9/21
to Google Apps Script Community
Thank you for replying. From your sample Spreadsheet, I proposed a sample script. Could you please confirm it? If that was not useful, I apologize.

function myFunction() {
  const sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Лист1");
  const values = sheet.getRange("A2:A" + sheet.getLastRow()).getValues();
  const today = new Date().getTime();
  values.forEach(([a], i) => {
    if (a.getTime() < today) {
      sheet.hideRows(i + 2, 1);
    }
  });
}


Роман Андриянов

unread,
Nov 11, 2021, 5:50:36 AM11/11/21
to Google Apps Script Community

Thx so much :) You are Beautiful)
Its WORKS!!!!!))))


среда, 10 ноября 2021 г. в 05:32:18 UTC+3, Tanaike:
Reply all
Reply to author
Forward
0 new messages