看板 CodeJob 關於我們 聯絡資訊
最近接了一個案子 在google sheet 的擴充功能內可以選Apps Script 打開後雖然中文標示錄製巨集, 但估計是google翻譯錯文字 應該就是google script editor 照客戶需求編寫了這段代碼 function myFun_onclick123123321321() { // Step 1: Get the position of the current cell (row, col) var sheet = SpreadsheetApp.getActiveSheet(); var cell = sheet.getActiveCell(); var row = cell.getRow(); var col = cell.getColumn(); // Step 2: Use VLOOKUP to get the value of the target cell in table2 var table2Sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("table2"); var lookupRange = table2Sheet.getRange("A:M"); var lookupValue = sheet.getRange(row + 4, col).getValue(); var columnIndex = 6; // You may need to adjust this depending on which column you want to look up var targetCell = SpreadsheetApp.functions.vlookup(lookupValue, lookupRange, columnIndex, false); // Step 3: If the value of the target cell in table2 is greater than 0, decrement it by 1 if (targetCell.getValue() > 0) { targetCell.setValue(targetCell.getValue() - 1); } } 代碼應該不是重點, 不過總之我點執行嘗試看看是否有bug時, 出現一個視窗: 需要授權 我選審查驗證之後需要重新登入google帳號 登入後出現以下文字: 系統已封鎖這個應用程式 這個應用程式嘗試存取您 Google 帳戶中的機密資訊。為保護您的帳戶,Google 已阻擋 這個存取行為。 ( 我把code簡短到什麼都沒寫也會出現此訊息) 請問大大知道怎麼讓google scrip寫好後可以使用嗎? -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 220.142.49.24 (臺灣) ※ 文章網址: https://www.ptt.cc/bbs/CodeJob/M.1677828986.A.77D.html ※ 編輯: seft584f8 (220.142.49.24 臺灣), 03/03/2023 15:38:43
LoveMoon: google it: Apps Script This app is blocked 03/03 20:33
seft584f8: 已經解決 謝謝 03/04 14:37