문제

Is it possible to use a captured value inside a getRange(value) code? If so, what do i need to change here? It keeps failing on the last line of code and i have tried a few different options.

function test(row) { 
  var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();// Define active sheet
  var amountdue = sheet.getRange("A30").getValue();// Capture amount due
  var rownumber = sheet.getRange("A30").getValue();// Capture row number
  sheet.getRange("B30").setValue(amountdue);// Paste amount due
  sheet.getRange("C"&rownumber).setValue(amountdue);// Paste amount due using captured row number
}
도움이 되었습니까?

해결책

try that code:

function test(row) { 
  var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();// Define active sheet
  var amountdue = sheet.getRange("A30").getValue();// Capture amount due
  var rownumber = sheet.getRange("A30").getRow()// Capture row number
  sheet.getRange("B30").setValue(amountdue);// Paste amount due
  sheet.getRange(rownumber,3).setValue(amountdue);// Paste amount due using captured row number
}

What I corrected:
when you are trying to get the row use the formula getRow().
When you are trying to set the value to a cell with the retrieved row use the formula getRange(Integer row,Integer column) to point the good cell.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top