google apps script - Condensing similar and repeating code -
I am quite a amateur coder but I have a solution and nothing has come.
I am working in Google Sheet and what I am trying to do, adds values of the same rows together in two separate columns. I have tried arrays, but in Array B. I did not get the first Aero to add the first element, so I prepared the code, it works fine, but it is very futile (there are 21 rows to connect with me ) looks like.
Would you at least be able to guide me to the right place to dilute it down?
var bd1 = data.getRange ("K3"); Var bn1 = data.getRange ("H3"). GetValue (); Var bo1 = Data. GetRange ("K3"). GetValue (); Var BS1 = BN1 + B1; bd1.setValue (BS1); Var BD2 = data. GreyRenz ("K4"); Var bn2 = data.getRange ("H4"). GetValue (); Var bo2 = Data. GetRange ("K4"). GetValue (); Var BS 2 = BN2 + B2; bd2.setValue (BS2); ...
One way to know about this is:
var add2Cells = function (labelA, labelB) {var cellA = data. getRange (labelA); Var Selb = Data. GateRnz (labeled); CellA.setValue (cellB.getValue (+) + cellA.getValue ()); }; add2Cells ("K3", "H3"); Add2Cells ("K4", "H4"); At this point you can create an array of pairs of cells that you loop through and feed into your add2Cells function.
Comments
Post a Comment