+ Reply to Thread
Results 1 to 3 of 3

Application-defined or object-defined error with vba .formula

  1. #1
    Registered User
    Join Date
    02-19-2013
    Location
    United States
    MS-Off Ver
    Excel 2003
    Posts
    2

    Application-defined or object-defined error with vba .formula

    I have a macro which inserts formulas into a worksheet for the purpose of correcting any errors that may have been created on the worksheet. The macro has worked fine entering long embedded If Statements. Now I update the macro and add some more formulas and although they follow the exact format as before I'm getting a Run Time Error 1004 "Application-defined of object-defined error".

    example of old formula: Cells(13, 132).Formula = "=IF(LEFT(EA13,3)=""Off"",0,IF(AND(EC13="""",(LEFT(DZ13,6)=""Called"")),0,IF(AND(EC13="""",(LEFT(DZ13,2)=""NC"")),""NCNS"",IF(AND(EC13="""",(LEFT(DZ13,2)=""Qu"")),0,IF(EC13<=0.2*(AND(EA13<=1)*AND(EA13>0.2)),1-EA13+EC13,IF(EC13>EA13,EC13-EA13,0))))))"

    example of new formula:Cells(13, 158).Formula = "IF(LEFT(E13,3)=""OFF"",0,IF(LEFT(D13,3)=""OFF"",0,IF(LEFT(D13,1)=""#"",0,IF(LEFT(F13,2)=""NC"",0,0.5,IF(LEFT(D13,6)=""CALLED"",0.5,IF(F13>0,F13,0))))))"

    I don't think it's the formula format as they're the same. I have several of these new statements and I have tried blocking them out in sequential order and I get the same error with the first that runs. Any ideas? Thanks

  2. #2
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Application-defined or object-defined error with vba .formula

    There is an error in your second formula

    Look at where you have IF(LEFT(F13,2)=""NC"",0,0.5,If

    delete the 0, or the 0.5,

  3. #3
    Registered User
    Join Date
    02-19-2013
    Location
    United States
    MS-Off Ver
    Excel 2003
    Posts
    2

    Re: Application-defined or object-defined error with vba .formula

    That was it! Thanks. I apologize for my poor editing.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1