Is there a way to include headers like DATE, TOTAL, NAME, etc. when displaying categories? Currently, only the results are visible.
function showInputBox(){
var ui = SpreadsheetApp.getUi();
var input = ui.prompt("Please enter your rep name.",ui.ButtonSet.OK_CANCEL);
if(input.getSelectedButton() == ui.Button.OK){
var ss = SpreadsheetApp.getActiveSpreadsheet();
var ws = ss.getSheetByName("Monitoring (Database)");
var data = ws.getRange("A2:X" + ws.getLastRow()).getValues();
var userSelectedRep = input.getResponseText().toLowerCase();
var newData = data.filter(function(r){ return r[23] .toLowerCase() == userSelectedRep});
var selectedColumns = newData.map(function (r) {
return [r[10], r[9], r[1], r[17], r[18], r[19], r[20], r[21], r[22]];
});
if (newData.length > 0){
var newWs = ss.insertSheet(userSelectedRep);
newWs.getRange(3, 3, selectedColumns.length, selectedColumns[0].length).setValues(selectedColumns);
} else {
ui.alert ("No Matching data found for the entered name.");
}
} else {
ui.alert("Operation Canceled.");
}
}
Even after changing getrange to A1:X, the outcome remains unchanged. Please refer to the screenshot below for more details.
Here is the current result image and I am looking to also display the header