单击消息框

时间:2019-02-21 15:24:07

标签: google-apps-script google-sheets

嗯,我已经参加了3个多小时了,但我还没有掌握。我是使用Google脚本的新手。 因此,我想遍历一个范围,获取它们的值,然后使用该值填充另一张纸。我已经能够获得第一个范围的值,但我希望它循环...我被卡住了...这是我的代码...

function va(){
  var app = SpreadsheetApp;
  var activeSheet = app.getActiveSpreadsheet().getActiveSheet();

  var ts = activeSheet.getRange("D4:D14").getValues();
  Logger.log(ts);

  var arr = [ts];
  var ss = app.getActiveSpreadsheet().getSheetByName("Tutor_Master's");
    ss.getRange("B11:B21").setValues(ts);
}

2 个答案:

答案 0 :(得分:0)

尝试使用UI类。 The documentation can be found here.我认为使用UI类的'alert'方法应该可以按照您希望的方式工作。

// Display "Hello, world" in a dialog box with an "OK" button. The user can 
// also close the
// dialog by clicking the close button in its title bar.
SpreadsheetApp.getUi().alert('Hello, world');

尽管“提示”方法也很适合您。

答案 1 :(得分:0)

是的,谢谢。我有点想通了。

//Assign a value from TA to TM 
  for ( i = 4; i <= lastColumnTA; i++){
    for ( j = 4 ; j <= lastRowTA; j++){ 

        //Get TA value and TA period
        var ValueTA= TA.getRange(j, i).getValue();
        var cTAHv= TA.getRange(rTAHn, i).getValue();
        var rTAHv = TA.getRange(j, cTAHn).getValue();
        var TAperiod = cTAHv.substring(0, 3) + " " + rTAHv;

        //Get columNum for TMperiod to be Populated
        for ( A = 2; A <= lastColumnTM; A++){
        if(TAperiod == TM.getRange(1, A).getValue()){
           break;
           };
        };

      //Populate TM period
        TM.getRange(k, A).setValue(ValueTA);
        }; 
  };