• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Numbers – Look-Up a Value in a Worksheet
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Numbers – Look-Up a Value in a Worksheet


  • Subject: Re: Numbers – Look-Up a Value in a Worksheet
  • From: Yvan KOENIG <email@hidden>
  • Date: Sat, 11 Feb 2017 11:56:39 +0100

I continued to play with Numbers and the lookup task.

set lookup to "125"
tell application "Numbers"
tell document 1 --"Some Document"
tell active sheet
tell tables
# On a sheet with two tables
set theCells to cells whose formatted value is lookup # returns a list of lists of cells
# If there is matches in both tables
--> {{cell "C10" of table 1 of sheet 1 of document id "85BABE62-4FFD-439C-B60E-D6565F9C9EB6", cell "D12" of table 1 of sheet 1 of document id "85BABE62-4FFD-439C-B60E-D6565F9C9EB6", cell "E14" of table 1 of sheet 1 of document id "85BABE62-4FFD-439C-B60E-D6565F9C9EB6"}, {cell "B3" of table 2 of sheet 1 of document id "85BABE62-4FFD-439C-B60E-D6565F9C9EB6"}}
# if there is a match only in table 2
--> {{}, {cell "B4" of table 2 of sheet 1 of document id "85BABE62-4FFD-439C-B60E-D6565F9C9EB6"}}
# If there is no match
--> {{}, {}}
set theCell to first cell whose formatted value is lookup # returns a list of cells
# If there is matches in both tables
--> {cell "C10" of table 1 of sheet 1 of document id "85BABE62-4FFD-439C-B60E-D6565F9C9EB6", cell "B3" of table 2 of sheet 1 of document id "85BABE62-4FFD-439C-B60E-D6565F9C9EB6"}
# if there is a match only in table 2
--> {missing value, cell "B4" of table 2 of sheet 1 of document id "85BABE62-4FFD-439C-B60E-D6565F9C9EB6"}
# If there is no match
--> {missing value, missing value}
(*
if theCell ≠ {} then
set theCell to last item of theCell
try
row of theCell as text
on error errMsg number errNbr
set theTable to item 1 of my decoupe(item 2 of my decoupe(errMsg, "«class NmTb» "), space)
end try
set theRow to theCell's row's address
set selection range to theCell
end if
*)
end tell
tell table 1
set theCells to cells whose formatted value is lookup # returns a list of lists of cells
# If there is matches in table 1
--> {cell "C10" of table 1 of sheet 1 of document id "85BABE62-4FFD-439C-B60E-D6565F9C9EB6", cell "D12" of table 1 of sheet 1 of document id "85BABE62-4FFD-439C-B60E-D6565F9C9EB6", cell "E14" of table 1 of sheet 1 of document id "85BABE62-4FFD-439C-B60E-D6565F9C9EB6"}
# If there is no match in table 1
--> {}
set theCell to first cell whose formatted value is lookup # returns a list of cells
# If there is matches in table  1
--> cell "C10" of table 1 of sheet 1 of document id "85BABE62-4FFD-439C-B60E-D6565F9C9EB6"
# If there is no match in table 1
--> error number -1719 from cell 1 of table 1 of active sheet of document 1 whose formatted value = "127"
(*
if theCell ≠ {} then
set theCell to last item of theCell
try
row of theCell as text
on error errMsg number errNbr
set theTable to item 1 of my decoupe(item 2 of my decoupe(errMsg, "«class NmTb» "), space)
end try
set theRow to theCell's row's address
set selection range to theCell
end if
*)
end tell
end tell
end tell
end tell

#=====

on decoupe(t, d)
local oTIDs, l
set {oTIDs, AppleScript's text item delimiters} to {AppleScript's text item delimiters, d}
set l to text items of t
set AppleScript's text item delimiters to oTIDs
return l
end decoupe

#=====


Yvan KOENIG running Sierra 10.12.3 in French (VALLAURIS, France) samedi 11 février 2017 11:51:07


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: Numbers – Look-Up a Value in a Worksheet
      • From: Christopher Stone <email@hidden>
    • Re: Numbers – Look-Up a Value in a Worksheet
      • From: Christopher Stone <email@hidden>
    • Re: Numbers – Look-Up a Value in a Worksheet
      • From: Christopher Stone <email@hidden>
References: 
 >Numbers – Look-Up a Value in a Worksheet (From: Christopher Stone <email@hidden>)

  • Prev by Date: Re: Numbers – Look-Up a Value in a Worksheet
  • Next by Date: Re: Numbers – Look-Up a Value in a Worksheet
  • Previous by thread: Re: Numbers – Look-Up a Value in a Worksheet
  • Next by thread: Re: Numbers – Look-Up a Value in a Worksheet
  • Index(es):
    • Date
    • Thread