ãã®è¨äºã§ã¯ãGoogle Apps Script (GAS) ã使ç¨ãã¦ãã¹ãã¬ããã·ã¼ãå ã®ãã¼ã¿ãããNGãã®ååæ å ±ãæ½åºããæ¡ä»¶ã«åè´ãããã¼ã¿ããã°ã«åºåããæ¹æ³ããç´¹ä»ãã¾ãã
ãµã³ãã«ã³ã¼ã
/**
* NGã®ååæ
å ±ããã°åºåãã¾ãã
*/
function NGã®ååæ
å ±ããã°åºå() {
ãã¹ã¦ã®ã·ã¼ããå¦çãã(function(sheet, index) {
var sheetName = sheet.getName();
var data = sheet.getDataRange().getValues(); // ã·ã¼ãå
¨ãã¼ã¿ãåå¾
var result = [];
var filteredRows = []; // æ¡ä»¶ãæºããè¡ãä¿å
// ãã¼ã¿ãã«ã¼ããã¦æ¡ä»¶ãæºããè¡ãåé
for (var i = 5; i < data.length; i++) { // ãã¼ã¿ã¯5è¡ç®ä»¥éã対象
var row = data[i];
if (
row[7] && row[7].toString() === "NG" && // Håï¼ã¤ã³ããã¯ã¹7ï¼ããNGãã¨çãã
row[16] !== "試ä½å" && // Qåï¼ã¤ã³ããã¯ã¹16ï¼ãã試ä½åãã§ãªã
row[16] !== "ãã¹ã" // Qåï¼ã¤ã³ããã¯ã¹16ï¼ãããã¹ããã§ãªã
) {
var rowData = [
sheetName, // ã·ã¼ãå
row[16], // Qåï¼ã«ãã´ãª1ï¼ã¤ã³ããã¯ã¹16ï¼
row[17], // Råï¼ã«ãã´ãª2ï¼ã¤ã³ããã¯ã¹17ï¼
row[3], // Dåï¼æ°éï¼ã¤ã³ããã¯ã¹3ï¼
row[4], // Eåï¼éé¡ï¼ã¤ã³ããã¯ã¹4ï¼
row[1] // Båï¼åååï¼ã¤ã³ããã¯ã¹1ï¼
];
filteredRows.push(rowData.join(",")); // æ¡ä»¶ã«åãè¡ãä¿å
}
}
// æ¡ä»¶ã«åãè¡ãããã確èª
if (filteredRows.length === 0) {
// NGã0件ã®å ´åã®ã¡ãã»ã¼ã¸
result.push(sheetName + "ï¼NG 0件ã§ãã");
} else {
// NGãããå ´åã®è¡¨é¡ã¨ãã¼ã¿
result.push("ã·ã¼ãå,ã«ãã´ãª1(Qå),ã«ãã´ãª2(Rå),æ°é(Då),éé¡(Eå),ååå(Bå)");
result = result.concat(filteredRows);
}
// ãã°ã«åºå
Logger.log(result.join("\n"));
});
}
ã³ã¼ãã®è§£èª¬
1. ãã¹ã¦ã®ã·ã¼ããå¦çãã
é¢æ°ã®å©ç¨
ãã®ã¹ã¯ãªããã¯ãæ±ç¨é¢æ° ãã¹ã¦ã®ã·ã¼ããå¦çãã
ãå©ç¨ãã¦ãã¹ãã¬ããã·ã¼ãå
ã®ãã¹ã¦ã®ã·ã¼ãã«å¯¾ãã¦å¦çãå®è¡ãã¦ãã¾ãã
以ä¸ã¯ ãã¹ã¦ã®ã·ã¼ããå¦çãã
é¢æ°ã®ä¾ã§ãï¼
function ãã¹ã¦ã®ã·ã¼ããå¦çãã(processSheet) {
var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
var sheets = spreadsheet.getSheets();
sheets.forEach(function(sheet, index) {
processSheet(sheet, index);
});
}
2. æ¡ä»¶ã«åºã¥ãããã¼ã¿ã®ãã£ã«ã¿ãªã³ã°
if (
row[7] && row[7].toString() === "NG" &&
row[16] !== "試ä½å" &&
row[16] !== "ãã¹ã"
) {
// ãã¼ã¿ãä¿å
}
- Håï¼ã¤ã³ããã¯ã¹ 7ï¼ã "NG" ã®å ´åã
- Qåï¼ã¤ã³ããã¯ã¹ 16ï¼ã "試ä½å" ã¾ã㯠"ãã¹ã" ã§ã¯ãªãå ´åã
ä¸è¨æ¡ä»¶ãæºããè¡ãæ½åºãã¾ãã
3. ãã°åºåã®ãã©ã¼ããã
æ¡ä»¶ãæºããè¡ãããå ´åã以ä¸ã®ãã©ã¼ãããã§ãã°ã«åºåãã¾ãï¼
ã·ã¼ãå,ã«ãã´ãª1(Qå),ã«ãã´ãª2(Rå),æ°é(Då),éé¡(Eå),ååå(Bå)
æ¡ä»¶ãæºããè¡ããªãå ´åã¯ããNG 0件ã§ãããã¨ãã°åºåããã¾ãã
å®è¡æ¹æ³
- Google ã¹ãã¬ããã·ã¼ã ãéããã¡ãã¥ã¼ãããæ¡å¼µæ©è½ãâãApps Scriptããé¸æã
- æ°ããã¹ã¯ãªããããã¸ã§ã¯ããä½æããä¸è¨ã³ã¼ããè²¼ãä»ãã
- ã¹ã¯ãªããã¨ãã£ã¿å
ã§
NGã®ååæ å ±ããã°åºå
ãå®è¡ã - å®è¡å¾ã
表示
âãã°
ã§çµæã確èªã
使ç¨ä¾
以ä¸ã®ãããªãã¼ã¿ãä¾ã«èãã¾ãï¼
Hå (NGå¤å®) | Qå (ã«ãã´ãª1) | Rå (ã«ãã´ãª2) | Då (æ°é) | Eå (éé¡) | Bå (ååå) |
---|---|---|---|---|---|
NG | 試ä½å | ã«ãã´ãªA | 10 | 5000 | ååA |
NG | æ£è¦å | ã«ãã´ãªB | 20 | 10000 | ååB |
NG | ãã¹ã | ã«ãã´ãªC | 5 | 2000 | ååC |
ã¹ã¯ãªãããå®è¡ããã¨ã以ä¸ããã°ã«åºåããã¾ãï¼
ã·ã¼ãå,ã«ãã´ãª1(Qå),ã«ãã´ãª2(Rå),æ°é(Då),éé¡(Eå),ååå(Bå) Sheet1,æ£è¦å,ã«ãã´ãªB,20,10000,ååB