LoginSignup

This article is a Private article. Only a writer and users who know the URL can access it.
Please change open range to public in publish setting if you want to share this article with other users.

More than 1 year has passed since last update.

自分用 機能美タスク管理GAS

Last updated at Posted at 2022-07-08

シンプルイズベストな機能美

junctionシートに起票、終わったら✔
チェック済みをarchiveシートにアーカイブする
(ぐちゃぐちゃになるので空白でないセルに色つけたい)

image.png

/**
 * メニューを追加
 */
function onOpen() {
  let ui = SpreadsheetApp.getUi()
  let menu = ui.createMenu('')
  menu.addItem('archive', 'archive')
  menu.addToUi()
}

/**
 * チェック済みの行を削除し、フラグリセット
 * A2からP〇まで
 */
function archive() {
  const junction = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('junction')
  const archive = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('archive')
  const formatDate = Utilities.formatDate(new Date(), "JST", "yyyy/MM/dd")
  Array(junction.getRange('A1').getValue()).fill(0).forEach((v, i) => {
    let row = i + 1
    if (row === 1) {
      return
    }
    // 未チェック
    if (!junction.getRange(`A${row}`).getValue()) {
      return
    }
    // チェック行
    let datas = junction.getRange(`B${row}:P${row}`).getValues()
    let insertRow = archive.getLastRow() + 1
    archive.getRange(`A${insertRow}`).setValue()
    archive.getRange(`B${insertRow}:P${insertRow}`).setValues(datas)
    junction.getRange(`B${row}:P${row}`).setValues([Array(15).fill('')])
    junction.getRange(`A${row}`).setValue(false)
  })
}
フィルタ.js
function filtering() {
  const sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('対象のシート名');
  // const sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();でもいいね
  if (sheet.getFilter() != null) {
    sheet.getFilter().remove();
  }
  // 空白のみ表示
  const rule_empty_only = SpreadsheetApp.newFilterCriteria()
    .whenCellEmpty()
    .build();
  sheet
    .getDataRange()
    .createFilter()
    .setColumnFilterCriteria(7, rule_empty_only) // G列を空白のみに
    .sort(3, true) // C列をASCソート
    .sort(6, true) // F列をASCソート
    .sort(5, true) // E列をASCソート
  ;
}

その他ほしいもの

・どっかのシートをimportrangeやqueryするfork系シート
・とりま書くホワイトボード(ぐちゃぐちゃになるので空白でないセルに色つけたい)
・カテゴリのリストのためのマスタ

0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up