sinahamidi wrote:
I'd like the order list to look something like this:
![User uploaded file](https://discussions.apple.com/content/attachment/764873040)
So once any ingredient in ingredient list is ticked it will be listed in the shopping list (order list). The list then gets exported to PDF and uploaded on cloud where a third party will have access to it to place the order.
It sounds as if you will be doing this quite often. If so a script may be a good solution (no extensive knowledge of scripts needed to use; just click and run).
The script below, for example, automatically produces this table on a new sheet that you can then File > Print > Print... and choose PDF as format.
![User uploaded file](https://discussions.apple.com/content/attachment/764793040)
I produced this by first clicking anywhere in this source table:
![User uploaded file](https://discussions.apple.com/content/attachment/764872040)
Then clicking the 'Run' button in Script Editor after copy-pasting the script below into Script Editor (in Applications > Utilities). You copy-paste in Script Editor the same as you would in any other application.
The script reads the checked items in the tables, reads their names and quantities, and automatically creates a shopping list table that can be printed to pdf.
If you haven't used Script Editor on your machine make sure Script Editor.app is checked in System Preferences > Security & Privacy > Privacy > Accessibility.
You should know within a minute or two of trying whether this approach will help. Some minor changes to the script may be needed if you've changed your table so that it is now different from your screenshot, but there is no need otherwise to get involved with AppleScript.
Be sure to first click anywhere in the source table first (the one with the checkmarks) before clicking the 'Run' button.
SG
tell application "Numbers"
tell (front document's active sheet's first table whose selection range's class is range)
set vv to rows'scells'svalue-- reads values into AppleScript list of lists (2D matrix) named vv
end tell
end tell
-- parameters are (vv, startRow, endRow, StartCol)
set theProteins to getChecked(vv, 3, 8, 1)
set theFrozens to getChecked(vv, 10, 10, 1)
set theDairies to getChecked(vv, 12, 19, 1)
set theDrinks to getChecked(vv, 21, 26, 1)
set theProduce to getChecked(vv, 3, 22, 4)
set theProduce2 to getChecked(vv, 3, 22, 7)
set theGroceries to getChecked(vv, 3, 26, 10)
set theGroceries2 to getChecked(vv, 3, 26, 13)
set ingredList to theProteins & theFrozens & theDairies & theDrinks & ¬
theProduce & theProduce2 & theGroceries & theGroceries2
tell application "Numbers" to tell front document
set newSheet to makenewsheet
tell newSheet
deletetables-- remove default table
set newTable to make new table with properties {name:"Shopping List", row count:2, column count:2, header column count:0, position:{100, 75}}
tell newTable-- these are cosmetic and could be omitted
set row 1's background color to "white"
set column 2's alignment to center
set cell 1's value to "Ingredient"
set cell 2's value to "Quantity"
end tell
repeat with i from 1 to ingredList's length
tell newTable
tell row (i + 1)
set cell 1's value to ingredList's item i's item 1
set cell 2's value to ingredList's item i's item 2
end tell
add row below last row
end tell
end repeat
end tell
end tell
to getChecked(theData, startRow, endRow, startCol)
set tempLst to {}
repeat with i from startRow to endRow
if theData's item i's (item (startCol + 2)) is true then
set n to theData's (item i)'s item startCol -- name
set q to theData's item i's item (startCol + 1) as integer -- quantity
copy {n, q} to tempLst's end
end if
end repeat
tempLst
end getChecked