1

매개 변수로 함수를 전달 :Google 스프레드 시트의 스크립트 : 나는 Google 시트에 스크립트를했습니다

/** 
* @param {array} input A row or a column. 
* @param {function} condition A function returning bool. 
* @return The last value in the input satisfying the condition. 
* @customfunction 
*/ 
function GetLastGoodValIn1DArray(input, condition) { 
    // realization ... 
} 

나는 다음 인수로이 함수를 호출하기 위해 노력하고있어 :

=GetLastGoodValIn1DArray(D11:H11;ISNUMBER) 

을 다음 오류가 발생합니다 :

Error

TypeError: #NAME? is not a function, but a string. (line 26).

분명히 'ISNUMBER'는 문자열로 해석됩니다. 그러나 이것을 함수로 전달하는 방법은 무엇입니까?

+0

은 화학식 올바르게 기록되지 않는다. '= GetLastGoodValIn1DArray (D11 : H11; ISNUMBER (something))'을 시도해보십시오. 여기서 값은 셀 참조 또는 값일 수 있습니다. –

답변

2

old google docs forumStack Overflow question에 따라 스크립트에서 내부 Google 시트 기능에 액세스 할 수 없습니다.

Google 시트 내부 기능도 매개 변수로 기능을 사용할 수 없습니다. 예를 들어 내부 함수 SUBTOTAL은 함수를 직접 가져 오는 대신 원하는 함수에 해당하는 숫자 코드를 사용합니다.

내가 생각할 수있는 가장 좋은 것은 vba를 위해 Excel처럼 사용자 고유의 WorksheetFunction 개체를 작성하는 것입니다. 그것은 문자열을 받아서 작성한 함수를 반환하는 객체 맵일 수 있습니다. 예를 들어

var worksheetFunction = { 
    isnumber: function (x) { 
    return !isNaN(x); 
    } 
}; 

Another Note: ISNUMBER isn't passed as a string to your custom function. Google sheets first calculates it as an error and then passes the string #NAME? to your custom function. You can see this by using the formula =type(ISNUMBER) , which returns 16 (the code for an error) also in your custom function condition === "#NAME?" will evaluate to true.

관련 문제