Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

284
Views
¿Cómo puedo agregar múltiples valores a múltiples celdas?

He hecho un ejemplo en las siguientes imágenes de cómo debería verse.

Me gustaría agregar stock al stock actual usando el script.

Si tomamos las imágenes como ejemplo, significaría que la columna Agregar inventario debe agregarse a la columna de inventario actual, en lugar de sobrescribirla.

Además, esto debe suceder en una hoja diferente.

Esto significa que en el ejemplo agregar valor de stock, la celda G5 debe ser 10 en la hoja de stock actual.

Si tiene más preguntas, no dude en preguntar.

Stock actual Añadir existencias

Pregunta:

El script que estoy usando ahora mismo es el siguiente:

 function V6() { const ss = SpreadsheetApp.getActive(); const sh0 = ss.getSheetByName('Sheet0'); const sh1 = ss.getSheetByName('Sheet1'); const vs = sh0.getRange('G4:I586').getValues(); vs.forEach(r => { r[2] += r[0]; r[0] = 0; }); [{in:0,out:7,sht:sh0},{in:2,out:9,sht:sh1}].forEach(e => { sh0.getRange(4, e.out, vs.length, 1).setValues(vs.map(r => [r[e.in]])); }); }

Si ejecuto este script, todos los valores de G4:G586 en Sheet0 se sumarán a I4:I586 en Sheet0

Pero lo que quiero que haga el script es agregar el valor de G4:G586 en Sheet0 a I4:I586 en Sheet 1.

 sh0.getRange(4, e.out, vs.length, 1).setValues(vs.map(r => [r[e.in]]));

Si cambio sh0 a sh1 en la fila de arriba, los valores no se sumarán sino que se sobrescribirán.

¿Podría ayudarme con la solución para que se sume en una hoja diferente?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Calcular y Cargar las columnas que han cambiado

 function inboeken() { const ss = SpreadsheetApp.getActive(); const sh = ss.getActiveSheet() const vs = sh.getRange('G4:I586').getValues();//getting all of the data at one time saves time vs.forEach(r => { r[2] += r[0]; r[0] = 0; }); [{in:0,out:7},{in:2,out:9}].forEach(e => { sh.getRange(4, e.out, vs.length, 1).setValues(vs.map(r => [r[e.in]]));//It only loads the two columns that have changed thus eliminating the risk of damaging formulas }); }

Esta matriz asigna los índices de los datos a las columnas de la hoja de cálculo.

 [{in:0,out:7},{in:2,out:9}]
  • para cada

  • mapa

Pregunta adicional:

Agregar una hoja

 function inboeken() { const ss = SpreadsheetApp.getActive(); const sr = 4; const sh0 = ss.getSheetByName('Sheet0'); const sh1 = ss.getSheetByName('Sheet1'); const vs = sh0.getRange('G4:I586').getValues();//getting all of the data at one time saves time vs.forEach(r => { r[2] += r[0]; r[0] = 0; }); [{in:0,out:7,sht:sh0},{in:2,out:9,sht:sh0},{in:2,out:9,sht:sh1},].forEach(e => { let sh = e.sht; sh.getRange(sr, e.out, vs.length, 1).setValues(vs.map(r => [r[e.in]]));//It only loads the two columns that have changed thus eliminating the risk of damaging formulas }); }
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!