0

I have two columns with numbers in them. I need a script I can call via menu to add these two columns, and then clear the value in the first. I have been unable to locate any examples on how to do this, so I don't have any attempted code.

Example:

 D12  E12
 10   26 

I would like a script that would change E12 to 36, then clear cell D12.

Erik Philips
  • 53,428
  • 11
  • 128
  • 150
user2317125
  • 11
  • 1
  • 1
  • how do you choose what cells to process ? is it always the same couple of columns ? you need to give more details and it would also be a good idea to show what you have tried so far ... – Serge insas Apr 24 '13 at 20:16

1 Answers1

1

You need to use getRange() http://goo.gl/vDqrA

I think this should do it.

var ss = SpreadsheetApp.getActiveSheet();
var num1 = ss.getRange("D12").getValue();
var num2 = ss.getRange("E12").getValue();
ss.getRange("E12").setValue(num1+num2);
ss.getRange("D12").clear();
miturbe
  • 715
  • 4
  • 17
  • Awesome! Works great...now I just need to figure out how to put the function into a menu option, I'm sure that is around here somewhere...Thanks for the help! – user2317125 Apr 25 '13 at 12:19