Applescript to determine if cell is a formula?

Perhaps I'm missing the obvious, but I can't seem to find any applescript support for determining if a cell contains a formula or is a literal value. 'get cell value' returns the resolved value rather than the formula string, and there doesn't seem to be an 'isformula' boolean property, nor is 'formula' a valid cell formatting type.
Any pointers?

It's quite easy
set rowNum to 80
set colnum to 3
set tName to 1
set sName to 1
set dName to 1
set isFormula to my isItAformula(rowNum, colnum, tName, sName, dName)
on isItAformula(rNum, cNum, t, s, d)
try
tell application "Numbers"
tell document d to tell sheet s to tell table t
set aCell to (get name of cell rNum of column cNum)
set aRange to aCell & ":" & aCell
set oldFormat to format of range aRange
set format of range aRange to text
set tVal to value of cell aCell
set format of range aRange to oldFormat
end tell -- document
end tell -- Numbers
return tVal starts with "="
on error
if my parleAnglais() then
error "row " & rNum & " of column " & cNum & " is out of range !"
else
error "ligne " & rNum & " de la colonne " & cNum & " est hors limites !"
end if
end try
end isItAformula
--=====
on parleAnglais()
local z
try
tell application "Numbers" to set z to localized string "Cancel"
on error
set z to "Cancel"
end try
return (z is not "Annuler")
end parleAnglais
Yvan KOENIG (from FRANCE dimanche 26 avril 2009 22:59:49)

Similar Messages

  • AppleScript to determine album ratings from song ratings and no. of tracks?

    Hi
    I am wondering if it would be possible to write an AppleScript to determine the album ratings for my albums in iTunes in the following way:
    All of my music collection comes from CDs I have ripped. I rip the whole album and then delete tracks I don't like. The number of tracks in the original album is preserved in the Track # field, e.g. Track 1 of 10, etc. All multi disc albums have been given the same name, i.e. they are recognised as the same album with Disc Number preserved, i.e. Disc #1 of 2, etc.
    The Album Rating would then be the sum of the rating of every song that is still in my iTunes Music Library divided by the total number of tracks in the original album (with multi disc albums counted as one album).
    So, for example, if I had an one disc album which originally had 10 tracks, that I only kept two songs from, and one of these tracks had a rating of 5 and the other 3, the album rating would be as follows:
    5+3/10 = 0.8
    Ideally this value would then be written to the Album Rating tag in iTunes. I think the best iTunes can do is display half-star ratings, but I wonder if it will still sort the Albums by Album Rating based on the actual value of the above calculation, i.e. an album with Rating 4.52 would be sorted higher than an album with rating 4.48, but both would show in iTunes as having 4 and a half stars?
    The next best option would be for the script to generate a text file of the Album Ratings sorted by rating with the highest first (in fact it would be good to have this in addition to the values being written to the Album Rating tags)
    The difference between this script and the built in method used in iTunes is that iTunes doesn't account for deleted tracks, so in the above example the Album would be rated 4, even though 8 tracks had been deleted.
    I hope this is clear and would be grateful for any help in getting this script together.
    Thanks,
    Nick.

    Here's an improved version of the script that should fulfill your needs (the modifications are in blue). The script now sorts the Album Ratings (via Numbers.app) and save them to a text file on the desktop, with no rating greater than 80. As previously, you must choose at least one track.
    --BEGINNING OF SCRIPT
    *tell application "iTunes"*
    --Make a list of all the selected albums:
    *set theAlbums to {}*
    *set theAlbumsRef to a reference to theAlbums*
    *set tempList to album of selection*
    *set thePreviousTitle to ""*
    *repeat with thisTitle in tempList*
    *set thisTitle to thisTitle as text*
    *if thisTitle is not thePreviousTitle then*
    *copy thisTitle to the end of theAlbumsRef*
    *set thePreviousTitle to thisTitle*
    *end if*
    *end repeat*
    *set numberOfAlbums to count theAlbums*
    --Make a list containing one track for each selected album:
    *set theTracks to {}*
    *set theTracksRef to a reference to theTracks*
    *repeat with thisAlbum in theAlbums*
    *copy (track 1 whose album is thisAlbum) to the end of theTracksRef*
    *end repeat*
    --Set the album rating of each album contained in the selection:
    *set theRatings to ""*
    *set k to 0*
    *repeat with thisTrack in theTracks*
    *set k to k + 1*
    *if k mod 25 = 0 then beep 1* -- for audio feedback
    *set thisAlbum to item k of theAlbums*
    *set numberOfTracks to 0*
    *repeat with k from 1 to (disc count of thisTrack)*
    try
    *get (track count of track 1 whose (album is thisAlbum) and (disc number is k))*
    *set numberOfTracks to numberOfTracks + result*
    *end try*
    *end repeat*
    *set songRating to 0*
    *repeat with R in (rating of tracks whose album is thisAlbum)*
    *if R > 80 then set R to 80*
    *set songRating to songRating + R*
    *end repeat*
    *set thisRating to round (songRating / numberOfTracks)*
    *set album rating of thisTrack to thisRating*
    *set theRatings to theRatings & (album artist of thisTrack & tab & thisAlbum & tab & (thisRating as text) & return)*
    *end repeat*
    *end tell*
    --Save the album ratings to a text file (on the dekstop):
    *set theTextFile to POSIX file (POSIX path of (path to desktop) & "iTunes Ratings")*
    *open for access theTextFile with write permission*
    *set eof theTextFile to 0*
    *write theRatings to theTextFile*
    *close access theTextFile*
    --Use application Numbers.app to sort the text file by rating:
    *tell application "Finder" to set NumbersWasOpen to (process "Numbers" exists)*
    *tell application "Numbers"*
    launch
    *open theTextFile*
    *tell table 1 of sheet 1 of front document*
    *sort by column 3 direction descending*
    *set theSortedRatings to ""*
    *repeat with j from 1 to numberOfAlbums*
    *set X to value of cell 1 of row j*
    *if X = 0 then set X to ""*
    *set Y to value of cell 2 of row j*
    *if Y = 0 then set Y to ""*
    *set Z to (value of cell 3 of row j) as integer*
    *set theSortedRatings to theSortedRatings & X & tab & Y & tab & Z & return*
    *end repeat*
    *end tell*
    *close front document without saving*
    *if not NumbersWasOpen then quit*
    *end tell*
    *open for access theTextFile with write permission*
    *set eof theTextFile to 0*
    *write theSortedRatings to theTextFile*
    *close access theTextFile*
    theSortedRatings
    --END OF SCRIPT
    Please let me know if anything doesn't work as expected.
    Message was edited by: Pierre L.

  • Can't find cell protection for formulas. Help!

    Would someone be so kind as to direct me to info on cell protection for formulas as found in xcel spreadsheets.
    What would Mac call it, seed/kernal protection or something? Thanks

    a,
    Your best bet, as I see it, is to put your equations and other sensitive data in one locked table and any input cells in another unlocked table or tables. You can arrange the tables in such a way as to simulate locking patches of a larger table as you might have done in Excel if you wish. None of this is iron clad. Anyone who knows how to unlock a table can do so and make changes. You are defending honest, well-intentioned users from mistakes, that's all. You can make mistakes pretty difficult to make with combinations of locked tables and clear masking objects over those tables to prevent selecting them.
    Regards,
    Jerry

  • How to determine which cell the user has just left?

    I want to check the contents of a JTable cell just after the user has left that cell.
    What is the most reliable way to determine which cell the user has just left?

    Hi,
    I use the cellRenderer for that... if the value is not correct, I call an editCellAt() method...
    JRG

  • Hi,  We are developing quite a few excel worksheet reports. The reports dont show the cells if contain formulas ( when opened in iPad or ipod  ),  is there any good solutions .

    Hi, 
    We are developing quite a few excel worksheet reports.
    The reports dont show the cells if contain formulas ( when opened in iPad or ipod  ),
    Is there any good solutions .
    Thanks.

    There is no version of Excel for iPads.  iPads come with something that lets you view the contents of Excel files but it implements only the common easy features and there are (literally) hundreds of things you can do in Excel that it doesn't know how to show on the screen, including some functions.
    If you intend to work with spreadsheets on an iPad I suggest you buy Numbers for iPad
    http://www.apple.com/apps/iwork/numbers/
    which understands more (but still not 100%) of the things that Excel does.  It is so cheap that you can probably afford to buy a copy just to see whether it does what you want.
    If you are doing things with spreadsheets and intend to be primarily working on iPads then I suggest you actually use Numbers on a Mac as well, rather than using Excel at all.

  • Applescript. Copy filtered cells in Excel

    I have a task for Applescript to filter Excel cells based on one criteria "NEW" in column "F" and then copy the filtered cells to a new spreadsheet (new file). I succeeded in filtering the data but now I can't figure out how to copy the result and paste it to the new Excel file. I can not manually define range because the filtered data will be different all the time, so I need automated way to identify the filtered range, select, copy and paste in into new CSV file. Thats what I have so far:
    tell application "Microsoft Excel"
              set myFile to "Macintosh HD:Users:JustDo:Desktop:AppleScript:Template.xlsx"
              set new_book to open workbook workbook file name myFile
              autofilter range range "A1:F1" field "6" criteria1 "NEW"
    end tell
    Thanks for your help

    Hi,
    JustDoItNow wrote:
    So, basically I would like to not to select rows above filter arrows and select everything below the filter rows.
    Thanks
    Ok,
    set tRow to missing value
    tell application "Microsoft Excel"
          set myFile to "Macintosh HD:Users:JustDo:Desktop:AppleScript:Template.xlsx"
          set new_book to open workbook workbook file name myFile
          autofilter range range "A1:F1" field "6" criteria1 "NEW"
          -- if you have only one list, remove the repeat and use this line --> set tRow to first row index of range object of list object 1 of active sheet
          repeat with tListObj in (get every list object of active sheet) --get first row index of the top list
                first row index of range object of tListObj
                tell the result to if tRow is missing value or it < tRow then set tRow to it
          end repeat
          tell active sheet
                set {tCol, lastCell} to {first column index, last cell} of used range
                set newRange to (get address of cell tRow of column tCol) & ":" & (get address of lastCell)
                select range newRange
          end tell
          copy range selection
    end tell

  • VBA Script Errors on Excel Cell containing a Formula

    I'm writing a VBA script.  When running the script I have a varible being set from a Excel cell containing a formula.  The script errors on this staement.  See below
            Range("O10").Select
            BlockSize = ActiveCell.FormulaR1C1 ' DID Block Size
    Cell O10 contains "=VLOOKUP(A1,SP_DID_Range!A:Q,10,FALSE)"
    The above formula produces the value 20
    What I receive is the formula instead of value the formula produces.
    I am trying retrieve the value and use it in another formula.  So "BlockSize" should equal 20 not "=VLOOKUP(A1,SP_DID_Range!A:Q,10,FALSE)"

    If you want the A1-style formula, use the Formula property.
    If you want the R1C1-style formula, use the FormulaR1C1 property.
    If you want the value, use the Value property:
        BlockSize = Range("O10").Value
    Note that it isn't necessary to select the cell.
    Regards, Hans Vogelaar (http://www.eileenslounge.com)

  • Cells not calculating formula

    I have a column of cells with a formula to add 5% to any value entered into those cells.  However when i enter a value, no calculations are done.  The only way i can seem to make this work is if i enter the formula one at a time to each cell after that cell is populated.  Is there any way to fix this.  I cant add this simple formula to 100's of cells individually every time the value is changed...

    You can't apply a formula upon the contents of the cell where it sits.
    If your values are in column C, starting from C2,
    In an other column, insert the formula = C2*1.05
    or better :
    =ROUND(C2*1.05,2)
    then apply fill down.
    Yvan KOENIG (VALLAURIS, France) mercredi 25 avril 2012
    iMac 21”5, i7, 2.8 GHz, 12 Gbytes, 1 Tbytes, mac OS X 10.6.8 and 10.7.3
    My Box account  is : http://www.box.com/s/00qnssoyeq2xvc22ra4k

  • Absolute cell reference in formula does not work when sorting. Previously posted solution does not work.

    I have two worksheets. Worksheet A has 5 columns. First Name, Last Name, Donation Amount, Donation Date, Contact Person. On the other worksheet I am trying to get the donations done or enabled by a certain
    contact person.  My formula is a simple addition: 
    ='Board_Donations_2013-2014'!D7+'Board_Donations_2013-2014'!D284
    It's a simple addition but when I sort Worksheet A by first name, or last name or any other way the amount/number on the cells change. D7 for example is $5,000, but when I sort the list by a different parameter
    it becomes $20,000 or whatever amount is on that cell now. I tried to use absolute reference, but it still changes.
    I want the amount/number on the cell (in this case D7 or D284) to stay consistent in the formula after sorting, not the cell location itself.
    I have office XP and Excel 2010.
    Any suggestions?
    Thanks,
    Rose

    Hi,
    Based on your required, we may add a Vlookup formula in the calculation process. It'll help us keep the relevant name & donation amount value after sorting. Please see the below image:
    Formula: =SUM(VLOOKUP("jonh",A2:E4,3,0),VLOOKUP("luna",A2:E4,3,0))
    http://office.microsoft.com/en-us/excel-help/vlookup-HP005209335.aspx
    Regards,
    George Zhao
    TechNet Community Support

  • How do I determine array size in a formula node

    I am feeding an array into a formula node to perform an operation on. However the size of the array can be an arbitrary size. How can I determine its size to use for iterating through a for loop?
    I suppose that I could add another input that is fed with the array size from the array palate but I would like to know if it can be done inside the formula node itself.

    Your own advice is the only and best one.
    greetings from the Netherlands

  • Is there a way to preserve interactivity within a table so that users of an iBook can enter new values in selected cells and have formulas recalculated with that input?

    I would like to include interactive tables that would recalculate using formulas I have written and values that the reader/user has entered into selected cells. The tables I've made in iBooks Author do contain formulas that work as expected...until exported to an iPad, then they look and act just like a static table. I am not looking for serious number crunching or high-end mathematics, although others might find great value in such capability.
    To work without a reader/user accidentally (or otherwise) altering formulas or formatting it would be necessary to lock some or most cells of the table. At present all cells are locked after export. Apple doesn't seem to envision or value the functionality of such a feature; it appears to me missing from Numbers as well.

    Should be near trivial to execute on with an app...
    As welll, I wouldn't be surprised if a dashcode widget would fit the bill.
    As always, feel free to use the 'Provide iBooks Author Feedback' menu item for features you'd like added in the future, etc.
    http://www.apple.com/feedback/ibooks-author.html

  • Struggling with Applying Cell refences of formulas to multiple cells

    Probably a basic question- I am new to Numbers.
    Ive been struggling for ages with applying a formula or cell reference to more than one cell at a time. If I select multiple cells (shift or command clicking them) - then I am unable to create a new 'Cell References'. Pressing the equals = sign merely gives me an error sound. And the formula bar is not accessible
    I have been struggling with this on and off now for about a week. Help - well it doesn't help and implies that I am doing the right thing, but it is not working. - Please help

    marky3 wrote:
    I ve been struggling for ages with applying a formula or cell reference to more than one cell at a time. If I select multiple cells (shift or command clicking them) - then I am unable to create a new 'Cell References'. Pressing the equals = sign merely gives me an error sound. And the formula bar is not accessible
    I have been struggling with this on and off now for about a week. Help - well it doesn't help and implies that I am doing the right thing, but it is not working. - Please help
    A better use for your time was to read carefully *Numbers User Guide* and *iWork Formulas and Fucnctions User Guide*.
    We may insert a reference to a range of cells in a cell's formula but we can't insert a formula in several cells with a single task.
    The correct protocol is :
    insert the formula in the first cell of the range then use the fill down (or fill up or fill to the right or fill to the left) feature.
    Yvan KOENIG (VALLAURIS, France) dimanche 21 février 2010 22:21:40

  • Using the $ to lock a cel in a formula

    Hi there,
    when i put a string in my formule to block the cel ( so i can draw the formule down) it just works fine. But after saving, closing and re-opening my file the formula has changed and doesn't work anymore!
    for example;
    I put an amount in cel B4 (let's say: € 4,50)
    in the cells B10 to B13 i put a figure.
    in cel C10 to C13 i want to have a formula that multiplies the figure from B10 to B13 with the amount in cel B4.
    that isn't to difficult,
    just type "=B$4*C10" in cel C10 and you're finished. Drawing down the formule into cel C11 to C13 just works fine.
    But after saving and reopening the file the formula has changed into:
    "=$B$4:$4*B10"
    it doesn't work anymore!
    can anybody tell me what i'm doing wrong? (i did this for years in excel)
    thanx in advance,
    Vincent

    Hi Vincent,
    After the original install Is Pages in its default location or did you move it to another location? The updater will look in the default location nowhere else.
    There are numerous post in this discussions where folks move Pages to another location to fit their needs, not a good thing. If you didn't move it to another location please search this discussion for "cannot update Pages" or the like; you'll see numerous suggestions.
    Do let us know, I hope that helps you.
    Sincerely,
    RicD

  • How to copy cell content without formula

    In numbers, how do I copy and paste the cell content without transferring the underlying formula?

    Use the menu item "Edit > Paste Values" when pasting instead of <COMMAND>+v (paste)
    Message was edited by: Wayne Contello

  • In a Macro, trying to code in VBA a formula and make it active at any time, so that when a cell is changed, formula is updated?

    I am trying to have this formula coded inside a macro and when the new worksheet is built, I need for the formula in the cell to be updated if any of the other components of the cell are changed.  I have tried several things, but so far I've
    had no success.
    =IF(ISBLANK(F14), " ", 3 / F16 / F14)
    This formula works fine when entered in the worksheet, but I am trying to avoid entering the formula again and again after the macro is run, every time. Can someone help me on this?
    Thanks
    Albert

    Yes, I had tried that before too... but I was getting a
    Runtime Error '1004'  Application-defined or Object-defined error
    Well, similar, because when I looked at your code, I saw that I was not closing my parenthesis... oops
    Now the code runs, but it is still not transferring the formula to my new sheet. 
    Anyways I have found my problem.
     I have a line in my code that does a  PasteSpecial Paste, and this is what is erasing my formula in excel. 
    I have modified that line, now my formula is transferring fine to my new sheet. 
    Nevertheless, I still don’t understand why the formula in code does not transfer… but well guess what I needed is working now.
    Thank you very much for your help
    Albert

Maybe you are looking for

  • Does the hp touchsmart 610 have a vga port?

    Does the HP Touchsmart 610 have a VGA Port to connect to a tv?

  • Client executed F.5E in Production run and told us no entries are

    Hi All, Issue: Client executed F.5E in Production run and told us no entries are generated. When they/i run 1.F.5D no error. 2.Initially when they run F.5E error is No postings can be created for company code 1000 Errors occur when determinig adjustm

  • HELP IN AWT Need to apply them within 6hrs

    import java.awt.*; import java.awt.event.*; class Seethis implements ItemListener      //Voting Screen Components      Frame Voting;      Panel p,p1,p2;      Checkbox ABC, XYZ, PQR, MNO, DES;      CheckboxGroup cbg;      Label chosen;      Button Vot

  • Java download link required

    What is the link for JDK 1.5.15 download link ? I visited http://www.oracle.com/technetwork/java/javasebusiness/downloads/java-archive-downloads-javase5-419410.html Are these JDK download links or JDK update links ?

  • How can I uninstall Adobe

    I downloaded the trial adobe but I dont need it. Now I want to uninstall becaue even the reader does not function