0

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
}

1 Answer 1

3

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.