0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

GAS:javaScriptでリスト化されたタイトルを各シートのrange(1,1)にsetValue()する

Last updated at Posted at 2020-06-03

環境

GAS

前提

criteriaシートのA1からB4まで、シート名とタイトルが記載されています。

qiita Practice.js
const this_spread = SpreadsheetApp.getActiveSpreadsheet();

function Main() {
  const name_map = createMap();
  const error_list = [];
 for ([key, value] of name_map){
    try{
    const target_sheet = this_spread.getSheetByName(key);
    target_sheet.getRange(1,1).setValue(key + '' + value); 
    }catch(error){
    error_list.push(key);
    }
  }
  if(error_list > 0){
    Browser.msgBox('error_list is ' + error_list);
  }
}

function createMap() {
  const criteria_sheet = this_spread.getSheetByName('criteria');
  let name_map = new Map();
  for(let count = 1; count <= 4; count ++){
    let key = criteria_sheet.getRange(count,1).getValue();
    let value = criteria_sheet.getRange(count,2).getValue();
    name_map.set(key, value);
  }
  return name_map
}

0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?