2016-10-05 3 views
-1

참고 약 1 년 전까지는 스프레드 시트를 본 적이 없었습니다.이 Google 스크립트를 설명해주세요.

나는 얼마 전에이 스크립트를 사용하고는했다!

function setFormulas() { 

    var sheet, startRow, i;  
    sheet = SpreadsheetApp.getActiveSheet(); 
    startRow = 7; 
    i = 3; 
    while(startRow < 5181) { 
    sheet.getRange(startRow, 2).setFormula('=AVL!V' + i); 
    i++; 
    startRow += 26; 
    } 
} 

그것은 같은 통합 문서에있는 탭 MER,에 수식 = 셀 B7에 AVL N3를 설정 한 다음 이 수식을 B7에서 시작하는 ColB의 모든 26 번째 셀과 ColB의 모든 26 번째 셀에서 시트 아래로 복사했습니다. 그래서

:

AVL!N3 went into B7 
AVL!N4 went into B33 
AVL!N5 went into B59 
AVL!N6 went into B85 

기타 등등 ...

그리고 총 31 회

. 나는 수식을 수동으로 조절하는 것이 악몽이 될 수 있으므로 72 개의 다른 시트 (보트 예약 시스템)에 대해이 작업을 수행해야합니다.

답변

1

필자는 함수의 각 단계가 수행하는 작업을 // 다음과 같이 작성했습니다. //는 행을 설명하는 설명을 나타냅니다.

function setFormulas() { 

    var sheet, startRow, i; //sets your variables 
    sheet = SpreadsheetApp.getActiveSheet(); //gets the sheet 
    startRow = 7; //sets the start row to 7 
    i = 3; //sets i to be the number 3 

    while(startRow < 5181) { //while startRow (which starts at 7) is less than 5181 keep doing this 
    sheet.getRange(startRow, 2).setFormula('=AVL!V' + i);//get the cell and set it to =ALV!V plus the value for i 
    i++; // add 1 to the value of i 
    startRow += 26; //increment startRow by adding 26 for each loop through 
    } 
} 
+0

톰 감사합니다! 그것은 명확한 것들이며 많은 도움이되었습니다. – Matt