Skip to content

Instantly share code, notes, and snippets.

@pfelipm
Last active May 23, 2021 22:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pfelipm/c689c665e441bb0a0f8358b848b8d249 to your computer and use it in GitHub Desktop.
Save pfelipm/c689c665e441bb0a0f8358b848b8d249 to your computer and use it in GitHub Desktop.
Función personalizada para HdC repetirFilas()
/**
* Repite cada fila un nº indicado de veces
* @param {A2:C4} intervaloDatos Intervalo de datos cuyas filas se van a repetir
* @param {D2:D4} colRepeticiones Vector columna que indica el nº de veces a repetior cada fila
* @customfunction
*/
function repetirFila(intervaloDatos, colRepeticiones) {
// ⚠️ ¡Se debería realizar un control de errores sobre los parámetros de la función!
const resultado = [];
intervaloDatos.forEach((fila, nFila) => {
for (let i = 0; i < colRepeticiones[nFila][0]; i++) {
resultado.push(fila);
}
});
return resultado;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment