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.

[Excel]交差するセルに特定の値があった場合、同列1行目の値を返す方法

Posted at

Looks like Spreadsheet, though tagged Excel : Question

const onOpen = () => {
    SpreadsheetApp.getActive().addMenu("Custom", [
        {
            name: "q256332",
            functionName: "q256332"
        }
    ]);
}
const q256332 = () => {
  const mark = "";
  const range = SpreadsheetApp.getActiveRange();
  let table = range.getValues();
  const header = table.shift();
  SpreadsheetApp.getActiveSheet().getRange(range.getRow()+table.length+2,range.getColumn(),table.length,2).setValues(table.map(item=>[item[0],(item.reduce((a,c,i)=>c===mark?a.concat(header[i]):a,[])).join(",")]));
}
  • From
A B C
A
B
C `
  • To
A C
B A,B
C A
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?