Skip to content

Instantly share code, notes, and snippets.

@tzkmx
Created June 10, 2026 20:15
Show Gist options
  • Select an option

  • Save tzkmx/d34028bd771bb0ac11682a905dbfbb05 to your computer and use it in GitHub Desktop.

Select an option

Save tzkmx/d34028bd771bb0ac11682a905dbfbb05 to your computer and use it in GitHub Desktop.
Test
function insertarFormulas() {
const ss = SpreadsheetApp.getActiveSpreadsheet();
let hoja = ss.getSheetByName("RESULTADO");
if (hoja) {
hoja.clearContents();
} else {
hoja = ss.insertSheet("RESULTADO");
}
for (let fila = 4; fila <= 100; fila++) {
// Columna A: contar ocurrencias del valor en B dentro del rango B4:B100
hoja.getRange(fila, 1).setFormula(
`=CONTAR.SI($B$4:$B$100,B${fila})`
);
// Columna C: buscar en hoja BASE el valor de B en columna B, traer columna H
hoja.getRange(fila, 3).setFormula(
`=IFERROR(BUSCARV(B${fila},BASE!$B:$H,7,0),"")`
);
// Columna F: marcar Repetida si A > 1, OK si no
hoja.getRange(fila, 6).setFormula(
`=SI(A${fila}>1,"Repetida","OK")`
);
}
SpreadsheetApp.getUi().alert("Fórmulas insertadas.");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment