Scripts
Insert Specified Value into Selected Cells
var Numbers = Application ("Numbers");
Numbers.includeStandardAdditions = true;
// get the selected cells
var tables = Numbers.documents[0].activeSheet.tables;
var ranges = tables.selectionRange.name();
for(var tableNum in ranges) {
var thisRange = ranges [tableNum];
if (thisRange != null) break;
}
var range = tables[tableNum].ranges[thisRange];
var cells = range.cells;
// set all cells to the date
for(var i=0;i<cells.length;i++) {
cells [i].value = "smol compute";
}
tables [tableNum].selectionRange = range;
Replace "smol compute" with the desired values.
// get the two tables involved
var Numbers = Application("Numbers");
var database = Numbers. documents [0].sheets [0].tables ['Database'];
var form = Numbers. documents [0].sheets [1].tables ['Data Entry'];
// get all of the values from the form
var values = [];
for(var i=0;i<form. rows. length;i++) {
var value = form. rows [i]. cells [0].value();
values.push (value);
}
//create a new row at the bottom of the database
var newRow = database.cells ['A'+database. rows.length].addRowBelow();
// put the values into that row
for(var i=0;i<values.length;i++) {
newRow.cells[i].value = values[i];
}
// clear out the form, going backwards so to end on the first cell
for(var i=form.rows.length-1;i>=0;i--) {
form.rows[i].cells[0].value = "";
}
Last updated