Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8425917
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T04:24:24+00:00 2026-06-10T04:24:24+00:00

How do I add a formula like: =SUM(A1:A17) to a range of fields using

  • 0

How do I add a formula like:

=SUM(A1:A17)

to a range of fields using Google Apps Script for Google Sheets?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T04:24:26+00:00Added an answer on June 10, 2026 at 4:24 am

    This is done using the setFormula for a selected cell. Below is an example of how to do this.

    var ss = SpreadsheetApp.getActiveSpreadsheet();
    var sheet = ss.getSheets()[0];
    
    var cell = sheet.getRange("B5");
    cell.setFormula("=SUM(B3:B4)");
    

    You can also use setFormulaR1C1 to create R1C1 notation formulas. Example below.

    var ss = SpreadsheetApp.getActiveSpreadsheet();
    var sheet = ss.getSheets()[0];
    
    var cell = sheet.getRange("B5");
    // This sets the formula to be the sum of the 3 rows above B5
    cell.setFormulaR1C1("=SUM(R[-3]C[0]:R[-1]C[0])");
    

    To add several formulas to several fields use setFormulas. Example below

    var ss = SpreadsheetApp.getActiveSpreadsheet();
    var sheet = ss.getSheets()[0];
    
    // This sets the formulas to be a row of sums, followed by a row of averages right below.
    // The size of the two-dimensional array must match the size of the range.
    var formulas = [
      ["=SUM(B2:B4)", "=SUM(C2:C4)", "=SUM(D2:D4)"],
      ["=AVERAGE(B2:B4)", "=AVERAGE(C2:C4)", "=AVERAGE(D2:D4)"]
    ];
    
    var cell = sheet.getRange("B5:D6");
    cell.setFormulas(formulas);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a class which I want to add a property with using formula
What formula would I use in a persisted column so that I can add
to add clarity to the below. I was considering using timers or storyboard.CurrentTimeInvalidated but
I'm trying to add a formula to a cell that already references an external
Can I sum these numbers with a formula ? 1 2 3 4 5
I'm trying to add a calculated field in a dataset with the following formula:
I would like to find c and t coefficients in simple result=x*t+c formula for
I have some info like below: 3/7 4/6 5/1 And I want a formula
I would like to do something like add a nice-to-Excel-functions Name property to the
When defining a calculated property using a formula in NHibernate, what are the implications

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.