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

148
Views
Agregar fila según el valor de la celda, debajo de los últimos datos en la columna A

Solo necesito ayuda, obtuve este código en YouTube que agrega filas a la hoja especificada, pero el código que obtuve solo agrega filas después de la fila 2 y sigue agregándola sin parar.

aquí está el código:

 function insertRow() { let spreadSheet = SpreadsheetApp.getActiveSpreadsheet(); let sheetToAdd = spreadSheet.getSheetByName('test sheet'); let lastRowEdit = sheetToAdd.getLastRow(); for(var i = 2; i <= lastRowEdit; i++) { sheetToAdd.insertRowAfter(i); } }

Lo que quiero es agregar una fila debajo de la última fila con datos en la columna A. Y el número de filas que se agregarán se basa en la celda B2 en otra hoja

hoja de cálculo de muestra: https://docs.google.com/spreadsheets/d/1sX6wS0ZPeLC1u0nbU2m8jeZ3dMVEXhkFPR_Ply27Z18/edit#gid=746083055

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

0

Este código puede resolver su problema: Requisito previo: una hoja de cálculo de Google con una hoja llamada Información que contenga la cantidad de filas para agregar en la celda 'B2'. Una hoja llamada 'agregar aquí' que se llenará con el siguiente script.

Al cambiarlo de acuerdo con los nombres de sus hojas, básicamente puede copiarlo.

Comentarios de ayuda!

 function insertRow() { let spreadSheet = SpreadsheetApp.getActiveSpreadsheet(); // activates the opened document let sheetToAdd = spreadSheet.getSheetByName('add here'); // selects the sheet at the bottom of the SpreadSheet (SpreadSheet is a collection of Sheets (!)) let rowsToAdd = spreadSheet.getSheetByName('Info').getRange(2,2).getValue(); // get cell B2 let lastRow = sheetToAdd.getLastRow() + 1; // you want to add after the last row with data for(var i = 0; i <= rowsToAdd; i++){ sheetToAdd.getRange(lastRow+i, 1).setValue(i); // get the cell at lastRow+counter and column 1; set the value as wished } }

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!