+ Reply to Thread
Results 1 to 9 of 9

Trouble with IF statement

  1. #1
    Registered User
    Join Date
    09-04-2013
    Location
    richardson, tx
    MS-Off Ver
    Excel 20037
    Posts
    28

    Trouble with IF statement

    I am trying to run the following code
    HTML Code: 
    However, the 2nd line produces an error: Run-time error '424': Object required.

    Any thoughts or suggestions where this error come from? I have similar code which runs as expected in another macro.

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,238

    Re: Trouble with IF statement

    How is test defined?


    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Registered User
    Join Date
    09-04-2013
    Location
    richardson, tx
    MS-Off Ver
    Excel 20037
    Posts
    28

    Re: Trouble with IF statement

    I did not explicitly define test. This is a temp var for use in the Do..Loop. I tried to define test as both DATE and VARIANT w/ no luck.

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,238

    Re: Trouble with IF statement

    Please Login or Register  to view this content.
    is a range. You then check if test is empty. Maybe try defining it as a range.

    Regards, TMS

  5. #5
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,238

    Re: Trouble with IF statement

    What value does n have when it fails?

  6. #6
    Registered User
    Join Date
    09-04-2013
    Location
    richardson, tx
    MS-Off Ver
    Excel 20037
    Posts
    28

    Re: Trouble with IF statement

    TMS, your suggestion took care of the error. However, even if
    HTML Code: 
    is empty, the IF statement executes. I wrote the value of test to an adjacent cell to ensure it was in fact empty.

  7. #7
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,238

    Re: Trouble with IF statement

    Maybe:

    Please Login or Register  to view this content.

    Regards, TMS

  8. #8
    Registered User
    Join Date
    09-04-2013
    Location
    richardson, tx
    MS-Off Ver
    Excel 20037
    Posts
    28

    Re: Trouble with IF statement

    TMS, that got it. Thanks for your help

  9. #9
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,238

    Re: Trouble with IF statement

    You're welcome. Thanks for the rep.



    If you are satisfied with the solution(s) provided, please mark your thread as Solved.


    New quick method:
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

    Or you can use this way:

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save


    You may also want to consider thanking those people who helped you by clicking on the little star at the bottom left of their reply to your question.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Trouble with IF statement
    By cre8tivspirit in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 11-05-2012, 02:49 PM
  2. Trouble with an IF statement
    By floricita in forum Excel General
    Replies: 21
    Last Post: 09-06-2011, 11:45 AM
  3. Excel 2007 : Trouble with IF statement
    By dillinger in forum Excel General
    Replies: 2
    Last Post: 10-09-2010, 11:47 AM
  4. IF statement trouble
    By softz in forum Excel General
    Replies: 4
    Last Post: 07-07-2009, 01:23 AM
  5. Trouble with If Then Else statement
    By JChandler22 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-06-2007, 02:51 PM

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