I am trying to work out a script so that when I press the + image on the attached screenshot it adds a new row and copies the formula that is in each cell. At the moment, I have the following script which adds a new row:-

function insertRowsAfter() {
  var ss = SpreadsheetApp.getActiveSpreadsheet()
  var s = ss.getActiveSheet()
  var cell = s.getActiveCell()
  var row = cell.getRow()
  var num = Browser.inputBox("Enter No. of rows:")

I need to add to the script so that the formulas in cells B18, D18 & E18 are included.

These are the formulas in each cell:

Cell B18 - A script is used to reset this cell so that it reads "Select Extras". This script is as follows:-

function ClearCells() {
var sheet = SpreadsheetApp.getActive().getSheetByName('Calculator');
sheet.getRange('B7').setValue('Select Panel');
sheet.getRange('B8').setValue('Select Mounting Equipment');
sheet.getRange('B9').setValue('Select Inverter');
sheet.getRange('B10').setValue('Select Smart Meter');
sheet.getRange('B13').setValue('Select Extras');
sheet.getRange('B14').setValue('Select Extras');
sheet.getRange('B15').setValue('Select Extras');


Cell D18 - The formula here is: =IFERROR(VLOOKUP(B18,Extras!A5:B24,2,FALSE),0)

Cell E18 - The formula here is: =+C18*D18

If someone can assist me that would be great.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.