smol compute
Premium Templates for Apple Numbers smolcompute.xyz
  • User Guides
  • ㅤ
    • Portfolio Tracker Pro
      • Quick Start
      • Accounts
      • The Dashboard
      • ROI Charts
      • Watchlists
      • Changing the Primary Currency
      • Optional Secondary Currency
      • Troubleshooting
      • Changelog
    • Portfolio Tracker Lite
      • Quick Start
      • Dashboard
      • Trade Log
      • Holdings
      • Changing the Primary Currency
      • Optional Secondary Currency
      • Troubleshooting
    • Formatter
      • Quick Start
      • Video Guides
      • Troubleshooting
    • General Guides
      • Tips and Tricks
      • Fixing an Erroneous Asset Match
      • Stocks Listed on Non-US Exchanges
      • Data Migration
      • Adding Accounts
      • Getting Updates
      • What devices can I use smol compute on?
      • Turning on End-to-End Encryption
      • Modifying your smol Tools
      • Sharing & Collaboration
      • Supported Non-US Stock Exchanges
      • Scripts
      • Brand Assets
  • ㅤ
    • smolcompute.xyz
    • X (Twitter)
    • Threads
    • YouTube
Powered by GitBook
On this page

Was this helpful?

  1. ㅤ
  2. General Guides

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 1 year ago

Was this helpful?