Last active
May 23, 2021 22:27
-
-
Save pfelipm/c689c665e441bb0a0f8358b848b8d249 to your computer and use it in GitHub Desktop.
Función personalizada para HdC repetirFilas()
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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