+ Reply to Thread
Results 1 to 4 of 4

Double IFs with exceptions

  1. #1
    Forum Contributor
    Join Date
    03-24-2009
    Location
    Vietnam
    MS-Off Ver
    Excel 2010
    Posts
    382

    Double IFs with exceptions

    Hello!
    OK, i feel ashamed for bringing this problem here to you folks, because I know that this is merely a simple syntax error (hopefully), but I spent too much time already trying to fix and just cannot figure it out.

    Belows code must be applied to the ActiveSheet, however, depending on the section, there might be an exception depending on the sheet name.

    Please Login or Register  to view this content.
    First, the general formatting section needs to be applied to all sheets which are I have activated beforehand (in a different macro), as long as cell A3 is not empty. If cell A3 is empty, the whole sub can be ended.
    Should the active sheet's name be "Company" though, then I need to skip the 2nd part of formatting, but still need to apply this part in case the name is any different.

    So basically it comes down to the a simple IF and ELSE statement job, but interestingly enough excel is ignoring me the exception for the Company sheet. Any idea why?

    Thanks for the help,
    A2k

  2. #2
    Forum Expert
    Join Date
    07-16-2010
    Location
    Northumberland, UK
    MS-Off Ver
    Excel 2007 (home), Excel 2010 (work)
    Posts
    3,054

    Re: Double IFs with exceptions

    If we look at your conditions (and snip the other lines) then we get ...

    Please Login or Register  to view this content.

    Does that explain where the problem is?

  3. #3
    Forum Contributor
    Join Date
    03-24-2009
    Location
    Vietnam
    MS-Off Ver
    Excel 2010
    Posts
    382

    Re: Double IFs with exceptions

    Thanks for the reply.
    OK, syntax is a ...., but lets try to get this resolved:

    Please Login or Register  to view this content.
    OK, first problem solved via closing the first IF and telling excel through ELSE that if there is no value in C3 to exit the sub.
    This seems to work fine now, thanks.

    Code runs on to part 2.
    Please Login or Register  to view this content.
    OK, first if statement has been closed, this second individual statement should merely check if the name of the active sheet is "Company" or not. If yes, Exit the sub, if no, follow the code.
    Well, it seems that the opposite case is happening now, as I am missing the formatting for all other sheets, and the Company sheet gets the formatting but I dont want to.
    Logically, the problem should be somewhere while defining the condition of the IF statement

    Please Login or Register  to view this content.
    change to
    Please Login or Register  to view this content.
    trying to make it definite by telling excel if the name really IS company, then end the sub.

    Obi Wan, thanks for the enlightment.

    Cheers,
    A2k

  4. #4
    Forum Expert
    Join Date
    07-16-2010
    Location
    Northumberland, UK
    MS-Off Ver
    Excel 2007 (home), Excel 2010 (work)
    Posts
    3,054

    Re: Double IFs with exceptions

    For the 2nd condition, if the worksheet name IS company you don't want to exit the sub, you just don't want to run the formatting code, so this should work fine ...

    Please Login or Register  to view this content.

    There's no need to use an Else statement, because the Else condition will basically be to do nothing at all.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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