Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

414
Views
Can I get name of cell by range in app script google sheet

I have code to calculate two cells by formula this is my code :

function myFunction() {
     var ss = SpreadsheetApp.getActiveSpreadsheet();
     var sh = ss.getSheetByName("sheet29");
     var maxR = sh.getMaxRows();

     var first = sh.getRange(maxR,6,1);
     var second = sh.getRange(maxR,7,1);

     var calculate = sh.getRange(maxR,8,1);

     first.setValue("2");
     second.setValue("2");

     var q = "F6"; // I want to change it to some thing like var q = first...;
     var qq =  "G6"; // I want to change it to some thing like var q = second...;

     var formula= ("=sum("+q+"+"+qq+")");
     calculate.setValue(formula);
 }

This code is fine calculate by formula by this code

var formula= ("=sum("+q+"+"+qq+")");
calculate.setValue(formula);

what I need, I don't know what is the name of cells to calculate, this dynamic. Any way to find the name of cell by range or another method

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You can get the A1 notation of a range by using range.getA1Notation() method and use it to set formula. Change your code

From:

 var q = "F6";
 var qq =  "G6";

To:

 var q = first.getA1Notation();
 var qq =  second.getA1Notation();

Reference:

  • Range.getA1Notation()
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!