hi, friend please help
in Numbers app,
every cell value of Column A is with one space after the number
it is like below:
7302626138 (one space at the end)
7302626137 (one space at the end)
is there any way to trim the space via applescript?
thanks very much!
Assuming that you run Numbers v 3.1 or higher, vou may try :
tell application "Numbers" to tell document 1 to tell active sheet to tell table 1
tell column 1
set nbr to count rows
repeat with r from 1 to nbr
set aVal to value of cell r
if aVal ends with space then
repeat while aVal ends with space
set aVal to text 1 thru -2 of aVal
end repeat
set value of cell r to aVal
end if
end repeat
end tell
end tell
Yvan KOENIG running El Capitan 10.11.3 in French (VALLAURIS, France) lundi 22 février 2016 15:18:07
hi, Yvan
thanks for your help
when I run the script, I got this. I am using Numbers 3.6.1
Numbers got an error: every row of column 1 of table 1 of active sheet of document 1 doesn’t understand the “count” message.
I apologize but I have no idea about that.
Before posting I tested with Numbers 3.6.1.
After reading your feedback, I just clicked upon [Open this Scriplet in your Editor] to get the script as it was delivered and it behaved flawlessly.
Just for see, I added two log instructions :
tell application "Numbers" to tell document 1 to tell active sheet to tell table 1
tell column 1
set nbr to count rows
log result # ADDED
repeat with r from 1 to nbr
set aVal to value of cell r
log result # ADDED
if aVal ends with space then
repeat while aVal ends with space
set aVal to text 1 thru -2 of aVal
end repeat
set value of cell r to aVal
end if
end repeat
end tell
end tell
The events log was :
tell application “Numbers”
count every row of column 1 of table 1 of active sheet of document 1
(22)
get value of cell 1 of column 1 of table 1 of active sheet of document 1
(missing value)
get value of cell 2 of column 1 of table 1 of active sheet of document 1
(4.5678E+4)
get value of cell 3 of column 1 of table 1 of active sheet of document 1
(123.0)
get value of cell 4 of column 1 of table 1 of active sheet of document 1
(541.0)
get value of cell 5 of column 1 of table 1 of active sheet of document 1
(741.0)
get value of cell 6 of column 1 of table 1 of active sheet of document 1
(589.0)
get value of cell 7 of column 1 of table 1 of active sheet of document 1
(missing value)
get value of cell 8 of column 1 of table 1 of active sheet of document 1
(missing value)
get value of cell 9 of column 1 of table 1 of active sheet of document 1
(missing value)
get value of cell 10 of column 1 of table 1 of active sheet of document 1
(missing value)
get value of cell 11 of column 1 of table 1 of active sheet of document 1
(missing value)
get value of cell 12 of column 1 of table 1 of active sheet of document 1
(missing value)
get value of cell 13 of column 1 of table 1 of active sheet of document 1
(missing value)
get value of cell 14 of column 1 of table 1 of active sheet of document 1
(missing value)
get value of cell 15 of column 1 of table 1 of active sheet of document 1
(missing value)
get value of cell 16 of column 1 of table 1 of active sheet of document 1
(missing value)
get value of cell 17 of column 1 of table 1 of active sheet of document 1
(missing value)
get value of cell 18 of column 1 of table 1 of active sheet of document 1
(missing value)
get value of cell 19 of column 1 of table 1 of active sheet of document 1
(missing value)
get value of cell 20 of column 1 of table 1 of active sheet of document 1
(missing value)
get value of cell 21 of column 1 of table 1 of active sheet of document 1
(missing value)
get value of cell 22 of column 1 of table 1 of active sheet of document 1
(missing value)
end tell
I got the same behavior with :
tell application "Numbers" to tell document 1 to tell active sheet to tell table 1
set nbr to count rows # MOVED
log result # ADDED
tell column 1
repeat with r from 1 to nbr
set aVal to value of cell r
log result # ADDED
if aVal ends with space then
repeat while aVal ends with space
set aVal to text 1 thru -2 of aVal
end repeat
set value of cell r to aVal
end if
end repeat
end tell
end tell
Yvan KOENIG running El Capitan 10.11.3 in French (VALLAURIS, France) mardi 23 février 2016 13:50:37