안녕하세요 onEdit 이쪽부분에서 오류가 나서 질문드립니다.
725
choi506088964208
投稿した質問数 2
0
let ws=SpreadsheetApp.getActiveSpreadsheet().getSheetByName("명렬표");
let ref=SpreadsheetApp.getActiveSpreadsheet().getSheetByName("이름");
let options=ref.getRange(2,1,ref.getLastRow()-1,2).getValues()
function onEdit(e){
const activerange=e.range;
const row=activerange.getRow()
const col=activerange.getColumn()
const val=activerange.getValue()
if (col===1){
const filteredoptions=options.filter(r=>r[0]===val)
const listofName=filteredoptions.map(r=>r[1])
const cell=ws.getRange(row,2)
setValidation(listofName,cell)
}
}
function setValidation(list,cell){
const rule=SpreadsheetApp.newDataValidation().requireValueInList(list).build()
ws.getRange(cell).setDataValidation(rule)
TypeError: Cannot read property 'range' of undefined
}
여기서 e.range 이부분에서 오류가 지속발생합니다. ㅠㅠ 부탁드립니다.
typeError
Google-Sheets
regex
回答 1
0
안녕하세요.
현재 작성하신 코드 확인 한 결과로는 아래 setValidation 함수 부문에서 아래가 누락이 되어 onEdit이 참조해야 되는데 실행 이 되지 않는 것으로 보입니다. ^^
cell.setDataValidation(rule)
아래와 같이 원본 코드를 보내드립니다. 비교해 보시면 차이점을 알 수 있을 것입니다.
let ws = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('master');
let ref = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('ref')
let options = ref.getRange(2, 1, ref.getLastRow()-1, 2).getValues()
function onEdit(e) {
const activerange = e.range;
const row = activerange.getRow()
const col = activerange.getColumn()
const val = activerange.getValue()
if(col === 1) {
const filteredoptions = options.filter(r => r[0] === val)
const listofName = filteredoptions.map(r => r[1])
// console.log(listofName)
const cell = ws.getRange(row, 2)
setValidation(listofName, cell)
}
if(col === 3) {
ws.getRange(row,4).setValue(new Date())
}
}
function setValidation(list,cell) {
const ws = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('master');
const rule = SpreadsheetApp.newDataValidation().requireValueInList(list).build()
cell.setDataValidation(rule)
}
강의자료 공유 부탁드립니다.
0
354
0
API강의문서 질문
0
371
1
강의자료 공유부탁드립니다.
0
388
1
안녕하세요 공유해주신 폴더에는 해당 2강에 대하여 '데이터 연결하기' 샘플 파일이 없는데요. 어떻게 해야하나요?
0
354
1
강의자료 공유 부탁드립니다.
0
277
0
함수 질문 드립니다!
0
339
1
강의 자료 부탁드립니다!
0
250
0
강의 자료부탁합니다!
0
189
0
강의 자료 공유 부탁드립니다
0
330
1
강의자료 공유 부탁드리겠습니다.
0
276
1
강의 자료 부탁드립니다.
0
256
1
안녕하세요 강의자료 어디서 참고하나요..?
0
271
1
강의자료 부탁드립니다
0
349
1
강의자료 부탁드립니다.
0
288
1
강의 자료 부탁드립니다.
0
202
1
강의자료 공유 부탁드립니다.
0
235
0
공유부탁드립니다
0
257
1
공유시트 부탁드립니다
0
229
1
공유 시트 부탁드립니다!
0
211
1
공유시트 부탁드립니다.
0
187
1
공유시트 부탁드립니다.
0
153
1
공유시트 부탁드려요
0
234
0
강사님 감사합니다 예제 시트 공유 부탁드립니다.
0
193
1
안녕하세요 강사님 1강을 듣고 공유폴더 접근권 부여 부탁드리려고 작성하였습니다.
0
173
1

