+ Reply to Thread
Results 1 to 11 of 11

If statement ignores colour index

  1. #1
    Forum Contributor
    Join Date
    04-07-2009
    Location
    Tasmania, Australia
    MS-Off Ver
    Excel 2003
    Posts
    158

    If statement ignores colour index

    For any duplicate found the last used cell in Column a will be found, but the If statement ignores that and calls the wrong sub. Screen updating Is on.

    What have I done wrong?

    thanks

    Steve W

    Please Login or Register  to view this content.

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: If statement ignores colour index

    Hello swallis,

    It seems to me, from your title, you are using conditional formatting to highlight the duplicates. Cell coloring applied by Conditional Formatting is not visible to VBA. Since your profile shows you are using Excel 2003, there is no easy workaround. In Excel 2007, a new Range property "DisplayFormat" was added. This will allow VBA to see Conditional Formatting colors.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Forum Contributor
    Join Date
    04-07-2009
    Location
    Tasmania, Australia
    MS-Off Ver
    Excel 2003
    Posts
    158

    Re: If statement ignores colour index

    The friend who'll be using this has Excel 2010. Does that mean it could be just a matter of adding "Range.LastRow.DisplayFormat" before the if statement and it'll work? Could I be so lucky?

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: If statement ignores colour index

    Hello swallis,

    In your macro your are setting the cell color to yellow if there are duplicates found. After first, I thought you were checking for cells highlighted by conditional formatting. That does appear to be the case. So, If you post a copy of the workbook then I will be able to follow what you are doing. Thanks.

  5. #5
    Forum Contributor
    Join Date
    04-07-2009
    Location
    Tasmania, Australia
    MS-Off Ver
    Excel 2003
    Posts
    158

    Re: If statement ignores colour index

    Thanks Leith. After your first message I made this Work around. It requires action by the user even if not a duplicate, which isn't very satisfying.

    Regards,

    Steve W
    Attached Files Attached Files
    Last edited by AliGW; 07-14-2019 at 03:38 AM. Reason: Please don't quote unnecessarily!

  6. #6
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,439

    Re: If statement ignores colour index

    I think we need the macro-enabled version (.xlsm).

    EDIT: Ignore! I see now you are using Excel 2003 ...
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  7. #7
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: If statement ignores colour index

    Hello swallis,

    Thanks for taking the time to put this together. It makes it much easier to follow. I take it from the workbook you are philatelist.

  8. #8
    Forum Contributor
    Join Date
    04-07-2009
    Location
    Tasmania, Australia
    MS-Off Ver
    Excel 2003
    Posts
    158

    Re: If statement ignores colour index

    I take it from the workbook you are philatelist.
    Not me. I'm trying to help a friend record her collection.

    Steve W

  9. #9
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,077

    Re: If statement ignores colour index

    You need to change ColorIndex to Color.

    But your code is highlighting the duplicate rows, not the last row.

  10. #10
    Forum Contributor
    Join Date
    04-07-2009
    Location
    Tasmania, Australia
    MS-Off Ver
    Excel 2003
    Posts
    158

    Re: If statement ignores colour index

    Thankyou, thankyou, thankyou Fluff13! That works perfectly.

    The way I've cobbled it together, the last row will always be one of the duplicates.

    very happy,

    Steve W

  11. #11
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,077

    Re: If statement ignores colour index

    You're welcome & thanks for the feedback

+ 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] Colour Index Number
    By rajeshn_in in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-15-2017, 05:40 AM
  2. [SOLVED] Changing the colour of a cell within an IF statement
    By wetfish in forum Excel General
    Replies: 10
    Last Post: 08-08-2012, 04:17 PM
  3. Replies: 2
    Last Post: 07-11-2012, 08:58 AM
  4. If statement from a cell colour
    By Kevpat in forum Excel General
    Replies: 8
    Last Post: 06-21-2011, 10:15 AM
  5. IF Statement - Change font colour?
    By Rimmers UK in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 10-10-2008, 08:45 PM
  6. Changing Cell colour using IF Statement?
    By robbiebrown34 in forum Excel General
    Replies: 3
    Last Post: 07-17-2007, 07:32 AM
  7. Fill Colour in IF statement??
    By skratch in forum Excel General
    Replies: 2
    Last Post: 09-27-2006, 08:18 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