i hope you can help me. I have this code, and i want to display an alert if the cell is blank, and also, if it is dont paste the information on my DB.
function Guardar() {
var hojaActiva = SpreadsheetApp.getActiveSpreadsheet();
var registro = hojaActiva.getSheetByName("Macro de Solicitud");
var bd = hojaActiva.getSheetByName("Respuestas Macro de Solicitud");
var valores = [
[
registro.getRange("c16").getValue(),
registro.getRange("j13").getValue(),
registro.getRange("f14").getValue(),
registro.getRange("c4").getValue(),
registro.getRange("c6").getValue(),
registro.getRange("c8").getValue(),
registro.getRange("c10").getValue(),
registro.getRange("c12").getValue(),
registro.getRange("c14").getValue(),
registro.getRange("f4").getValue(),
registro.getRange("f6").getValue(),
registro.getRange("f8").getValue(),
registro.getRange("f10").getValue(),
registro.getRange("f12").getValue(),
registro.getRange("f16").getValue()
]
];
bd.getRange(bd.getLastRow() 1, 1, 1, 15).setValues(valores);
}
CodePudding user response:
Alert if range is blank
function lfunko() {
const ss = SpreadsheetApp.getActive();
const sh = ss.getSheetByName("Sheet0");
const ui = SpreadsheetApp.getUi();
const rgl = sh.getRangeList(["c16","j13","f14","c4","c6","c8","c10","c12","c14","f4","f6","f8","f10","f12"]);
rgl.getRanges().forEach(r => {if(r.isBlank()){ui.alert(`${r.getA1Notation()} is blank`)}});
}
CodePudding user response:
In your sheet names 'Macro de Solicitud' add a formula in a cell that count the number of values in C16,J13,F14,etc. and compare with the number of cells. By checking the result you will find if one at least cell is blank before pasting the informations in your data base..