Trying to copy values from another tab but keep getting error “function getValues() can not be used as the left-hand side”

百般思念 提交于 2021-02-05 12:10:39

问题


I used my code for about a week (which was already very slow) but kept going. Today, while trying to run it, I get the message "ReferenceError: Function function getValues() {/* */} can not be used as the left-hand side of assignment or as an operand of ++ or -- operator."

Here's the code:

    function PreenchePlanilha()
    {
      var App = SpreadsheetApp;
      App.getActiveSpreadsheet().getSheetByName('MacroHelp').getRange(1,1).activate();
      var helpMacro = App.getActiveSpreadsheet().getActiveSheet();
      var i = 250;
      var j = 1;
      var k = 1;
      while (helpMacro.getRange(i,5).getValue() != "")
      {
      if(helpMacro.getRange(i,17).getValue() == "")
      {
        while (helpMacro.getRange(j,20).getValues().toString() != helpMacro.getRange(i,5).getValues().toString())
        {
          j = j+1;
        }

        var aba = helpMacro.getRange(j,21).getValue();
        var valores = helpMacro.getRange(i,6, 1, 11);
        var email = helpMacro.getRange(i,1).getValue();

        App.getActiveSpreadsheet().getSheetByName(aba).getRange(1,1).activate();
        var cols = contalinha();

        while (App.getActiveSpreadsheet().getActiveSheet().getRange(k,8).getValue() != email && k <= cols)
        {
          k = k + 1;
        } 

        App.getActiveSpreadsheet().getActiveSheet().getRange(k,31,1,11).getValues() = helpMacro.getRange(i,6, 1, 11);
        App.getActiveSpreadsheet().getSheetByName("MacroHelp").getRange(i,17).activate();
        App.getActive().getCurrentCell().setValue('Feito');
        }
        i++;
        j = 1;
        k = 1;

      }



}


function contalinha() {
  var spreadsheet = SpreadsheetApp.getActive();
  spreadsheet.getRange('A1').activate();
  spreadsheet.getCurrentCell().getNextDataCell(SpreadsheetApp.Direction.DOWN).activate();
  var cols = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet().getActiveRange().getRow();
  return cols;
};

I tried replacing the line

App.getActiveSpreadsheet().getActiveSheet().getRange(k,31,1,11).getValues() = helpMacro.getRange(i,6, 1, 11);

I tried both this codes, none working:

App.getActiveSpreadsheet().getActiveSheet().getRange(k,31,1,11).setValues() = valores;
App.getActiveSpreadsheet().getActiveSheet().getRange(k,31,1,11).setValues(valores);

What am I doing wrong?


回答1:


I managed to get it done! I had to change this line

App.getActiveSpreadsheet().getActiveSheet().getRange(k,31,1,11).getValues() = helpMacro.getRange(i,6, 1, 11)

and changed it into this:

App.getActiveSpreadsheet().getActiveSheet().getRange(k,31,1,11).setValues(helpMacro.getRange(i,6, 1, 11).getValues());

Thanks for the help!



来源:https://stackoverflow.com/questions/58661595/trying-to-copy-values-from-another-tab-but-keep-getting-error-function-getvalue

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!