Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 385
  • Last Modified:

Google Spreadsheet Script: Auto Iterate Next Row

I am a  newb when it comes to this stuff but I've been playing around Google App Script for a Google Spreadsheet and hoping someone can help/teach me how to customize code.

I found this code to populate data in my spreadsheet:
 
The spreadsheet I have is 6 columns wide (A-F) and what I want to do is customize the code so that as I enter information in a new row in column A, columns B-F will auto-populate.  I know I can just drag the formulas down, but it would be a "nice to have" to just have to auto populate.

I know Google App Script has a command called "getLastRow"  that can facilitate this problem, I'm just not sure how to set it up.

Thanks for the help.
0
Matthew Nguyen
Asked:
Matthew Nguyen
  • 2
  • 2
1 Solution
 
Chris BottomleyCommented:
The specifics for getlastrow are:

var sh = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
// Use whatever you have established for the sheet already ... provided for clarity only

var rw = sh.getLastRow() + 1;
// getlastrow being the last populated row therefore plus 1 for the required row.

Chris
0
 
Chris BottomleyCommented:
In the absence of any update from you, taking it a step further and showing for example a way of posting the formulae then:

Chris
var sht = SpreadsheetApp.getActiveSheet();
  var rw = sht.getLastRow();
  var str

  sht.getRange(rw, 2).setValue (2);
  sht.getRange(rw, 3).setValue (3);
  str = 'B' + rw + ':C' + rw;
  sht.getRange(rw, 4).setFormula ('=sum(' + str + ')');
  str = 'B' + rw + ',C' + rw;
  sht.getRange(rw, 5).setFormula ('multiply(' + str + ')');

Open in new window

0
 
Matthew NguyenSenior Associate: Social ListeningAuthor Commented:
Sorry, I was out all weekend, let me give this a go and see if I can get it to work, thanks for the help.

Matt
0
 
Matthew NguyenSenior Associate: Social ListeningAuthor Commented:
Thanks
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now