Consulting

Results 1 to 4 of 4

Thread: complie error: Expected: end of statement

  1. #1

    complie error: Expected: end of statement

    Hey guys

    I'm simply trying to assign the following formula to a cell like this:

    Range("P2") = "=IF(M2=100,"Complete",IF(J2<TODAY(),"Overdue",IF(J2-30<TODAY(),"Next Period","Future")))"

    but I'm getting compile error: Expected: end of statement

    Any help much appreciated

  2. #2
    Moderator VBAX Master austenr's Avatar
    Joined
    Sep 2004
    Location
    Maine
    Posts
    2,033
    Location
    try this in P2 and copy down or wherever you need it to be.

    =IF(M2=100,"Complete",IF(J2<TODAY(),"Overdue",IF(J2-30<TODAY(),"Next Period","Future")))
    Peace of mind is found in some of the strangest places.

  3. #3
    VBAX Guru mancubus's Avatar
    Joined
    Dec 2010
    Location
    "Where I lay my head is home" :D
    Posts
    2,644
    PHP Code:
    Range("P2").Formula "=IF(M2=100,""Complete"",IF(J2<TODAY(),""Overdue"",IF(J2-30<TODAY(),""Next Period"",""Future"")))" 
    double the quotes for strings in formulas.

    write this worksheet formula in a cell
    turn macro recorder on
    select the cell
    press F2 key then Enter
    turn macro recorder off

    open VBE window (Alt+F11) to see what macro recorder produced.
    PLS DO NOT PM; OPEN A THREAD INSTEAD!!!

    1) Posting Code
    [CODE]PasteYourCodeHere[/CODE]
    (or paste your code, select it, click # button)

    2) Uploading File(s)
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) (multiple files can be selected while holding Ctrl key) / Upload Files / Done
    Replace company specific / sensitive / confidential data. Include so many rows and sheets etc in the uploaded workbook to enable the helpers visualize the data and table structure. Helpers do not need the entire workbook.

    3) Testing the Codes
    always back up your files before testing the codes.

    4) Marking the Thread as Solved
    from Thread Tools (on the top right corner, above the first message)

  4. #4
    Thanks mancubus, that did it.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •