Is this a feasible Macro? Extracting details from text file?

With this in Numbers:

15-pty-fs8
Untitled.numbers.zip (55.5 KB)

…and assuming the sheet is open in Numbers, this works for me:

33-pty-fs8
[test] Search for Number and Return Adjacent Cell in Numbers.app.kmmacros (3.4 KB)


Notes:

  • In the sheet, the cell with the “unique numerical number” has to be formatted as number. If it is formatted as text, remove the as number in line 3 of the script.
  • Not tested with a large dataset; maybe it is too slow.
    • If the unique number is always in the same column, you could limit the search to that column.

The contained script:

tell application id "com.stairways.keyboardmaestro.engine"
  set inst to system attribute "KMINSTANCE"
  set targetNumber to (getvariable "Local__Search for Number" instance inst) as number
end tell

tell application id "com.apple.iWork.Numbers" -- Numbers
  tell document 1
    tell active sheet
      tell table 1
        set theMatch to (first cell whose value is targetNumber)
        set {r, c} to {row's address, column's address} of theMatch
        tell row r to set adjacentCell to cell (c - 1)
        value of adjacentCell
      end tell
    end tell
  end tell
end tell
2 Likes