2016-06-17 3 views
0

조건부 다중 연결을 설정하려고하는데 거의 다 있습니다.셀 범위의 조건부 연결

원칙은 (SUMIF처럼) 하나의 행/열을 따라 실행하며 값이 조건과 일치하면 합계 범위에서 해당 값을 가져 와서 함께 추가합니다. 이 시간에 우리는 그것들을 연결하고 있습니다. (문자 그대로 그것들을 더합니다!) 이 그림은 예상 결과와 내가 할 수있는 것보다 더 잘 설명해야 할 실제 결과를 보여줍니다. Spreadsheet 내가 데 문제는 여기에

코드의 ... 상관없이 마지막 매개 변수로 I 입력 여전히 (여전히 쉼표 등을 제공합니다 "#"을 입력) 어떤 공백없이 쉼표를 제공하지 않는다는 것이다 :

/** 
 
* Concatenates a range of cells where the condition is met. 
 
* 
 
* @param {A4:A6} cRange The dynamic cell range to test. 
 
* @param {"Condition"} cCondition The string that the cell should match. 
 
* @param {A4:A6} pRange The dynamic cell range to concatenate. 
 
* @param {", "} interspace A string to insert between each entry. 
 
* @return The a concatenated range of cells 
 
* @customfunction 
 
*/ 
 
function conditionalMultiConcat(cRange, cCondition, pRange, interspace){ 
 
    var ss = SpreadsheetApp.getActiveSpreadsheet(); //get the active workbook 
 
    var sheet = ss.getSheets()[0]; //get the active sheet 
 
    //var values = sheet.getRange(pRange).getValues(); //debug line - uncomment to see the values 
 
    var values = "" //set the return value to blank 
 
    for(var cc = 0; cc < pRange.length; ++cc) { //For each value in the array 
 
    if ((cc == 0 || cc == pRange.length - 1) && (cRange[cc] = cCondition)) { //if it's the first or last value AND it matches our condition 
 
     values = values + pRange[cc].toString();// concatenate without interspace 
 
    } 
 
    else if (cRange[cc] = cCondition){ //else if it matches our condition then concatenate with the interspace 
 
     values = values + interspace + pRange[cc].toString();// concatenate 
 
    } 
 
    } 
 
    return values; 
 
}

내가 무슨 말이냐? 감사합니다. .

답변

1

나는 공식 당신을 위해이 작업을 수행 할 수 있다고 생각 :

=JOIN(",",FILTER(B1:D1,B2:D2="Y"))

+0

덕분에이 작품과 내 방법보다 훨씬 간단합니다. 가능한 경우 내 실수가 코드에있는 곳을 알고 싶으므로 gscripting을 향상시킬 수 있습니다. – Zaberi

관련 문제