+ Reply to Thread
Results 1 to 11 of 11

Conditional Formatting/Duplicates

  1. #1
    Registered User
    Join Date
    03-19-2009
    Location
    Houston, TX
    MS-Off Ver
    Excel 2003
    Posts
    5

    Conditional Formatting/Duplicates

    Hello all,
    My background is many years of Access VBA. From time to time, I'm called upon to work in Excel. I am not that familiar with the library.

    I'd like to know if it is possible to do the following:

    Examine Column 1 and, for each like value, examine Columns 2 and 3 for duplicate values. Highlight or conditionally format the duplicates in Columns 2 and 3 (again, for each like value in Column 1).

    Being that I've coded Access applications for quite some time, I am sure it can be done...I just don't yet know exactly how. I've searched the archive for and found some examples which deal with duplicate data, but have found none yet which quite fit my scenario.

    Could someone help me out, please?

    I will continue searching the many threads matching my keywords in the meantime.

    Many thanks.

    Oh, sorry to impose even more...I've found sample code which enforces rules and conditionally formats cells when new data is added. It works fine and I understand it. I'm hoping the kind soul who might help me with the above can explain how I might do both things on the code page.

    I assume the Worksheet_Change Event would contain the "enforcement" code.
    Attached Files Attached Files

  2. #2
    Valued Forum Contributor Charles's Avatar
    Join Date
    02-10-2004
    Location
    Biloxi
    MS-Off Ver
    Windows 7, Excel 2003,2007 & Mac2011
    Posts
    845

    Re: Conditional Formatting/Duplicates

    Hi,

    Check
    http://www.excelforum.com/excel-prog...her-sheet.html
    and look at Filters.xls.
    The code look at dupes and moved the dupe to another sheet.
    If there was only 1 occurrence of the data it was not copied to the other sheet.
    Charles

    There are other ways to do this, this is but 1 !
    Be Sure you thank those who helped.
    IF YOU'RE SATISFIED BY ANY MEMBERS RESPONSE TO YOUR ISSUE PLEASE USE THE STAR ICON AT THE BOTTOM LEFT OF THE POST UNDER THEIR NAME.

  3. #3
    Registered User
    Join Date
    03-19-2009
    Location
    Houston, TX
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Conditional Formatting/Duplicates

    Thank you very much, Charles.

    However, running the macros results in run-time Error 1004, on this line:

    Please Login or Register  to view this content.
    I note that Option Explicit is off and that the code is very sloppy. I'll keep searching for similiar code which works.

    I think I see the gist of it, but I'm still not there.

    Many thanks.
    Last edited by VBA Noob; 03-20-2009 at 05:11 PM.

  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: Conditional Formatting/Duplicates

    Hello vba-dev,

    Your profile says you use Excel 2003. The workbook you posted in Excel 2007 format which is probably what you use at work. You will get more responses if post a copy of the workbook in 2003 format also. Unless there is some backward compatibility problems that prevent this.
    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!)

  5. #5
    Registered User
    Join Date
    03-19-2009
    Location
    Houston, TX
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Conditional Formatting/Duplicates

    Thank you, Leith.

    Yes, the person I'm trying to help uses 2007. When I opened it at home, I noticed that Excel 2003 is doing some conversion on the fly.

    When I do a File SaveAs, Excel 2003 is not a choice on the list. However, I ran the file through the Remove Hidden Data tool just now and it saved with the .xls extension. I don't honestly know what format it saved as, or quite how to tell.

    It's property sheet shows it now as Type: Microsoft Excel Worksheet. I believe it's in 2003 format now. I note that the 2007 "Types" are quite different.

    Thanks for the tip.
    Attached Files Attached Files

  6. #6
    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: Conditional Formatting/Duplicates

    Hello vba-dev,

    The workbook opens in 2003. Sheet1 has has "Team", "Date 1", and "Date 2". Is that all the data? Sheets 2 & 3 are blank.

  7. #7
    Registered User
    Join Date
    03-19-2009
    Location
    Houston, TX
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Conditional Formatting/Duplicates

    Yes, Leith, that's it. It is as I received it from the gentleman who asked me to help him with the above issue.
    Last edited by vba-dev; 03-20-2009 at 12:31 AM.

  8. #8
    Valued Forum Contributor Charles's Avatar
    Join Date
    02-10-2004
    Location
    Biloxi
    MS-Off Ver
    Windows 7, Excel 2003,2007 & Mac2011
    Posts
    845

    Re: Conditional Formatting/Duplicates

    Sorry the code did not work for you. It did and does work at my end.

    Now, I'm not one to complain and I do the what I can to help others.
    So I'm a little offended by this.

    I note that Option Explicit is off and that the code is very sloppy. I'll keep searching for similiar code which works.

  9. #9
    Registered User
    Join Date
    03-19-2009
    Location
    Houston, TX
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Conditional Formatting/Duplicates

    Charles,

    There is a comment in the code which attributes it to someone's web site:

    '' NoDupes came from John W's web'' thanks to him''

    I assumed it was borrowed from a web site. If you wrote it, sorry about that. I meant no offense. I simply meant to point out that coding with Option Explicit set to Off is bad practice and leads to sloppy code. And, sorry to say, it is sloppy. I do appreciate your help, and hope you can appreciate my pointing out the obvious. The Sub gets me closer to where I need to be in understanding this problem.

    Again, no offense meant.

  10. #10
    Valued Forum Contributor Charles's Avatar
    Join Date
    02-10-2004
    Location
    Biloxi
    MS-Off Ver
    Windows 7, Excel 2003,2007 & Mac2011
    Posts
    845

    Re: Conditional Formatting/Duplicates

    Ok,

    Thought I'd give this another go.
    Modified code so that it will look for Dup's in column B and at same time see if dups in column C. If there are dups in columnC then highlite.
    Did not set code to look at column D.
    Attached Files Attached Files

  11. #11
    Forum Contributor mewingkitty's Avatar
    Join Date
    09-29-2008
    Location
    Fort McMurray, Alberta, Canada
    MS-Off Ver
    Excel 2003
    Posts
    949

    Re: Conditional Formatting/Duplicates

    Examine Column 1 and, for each like value, examine Columns 2 and 3 for duplicate values. Highlight or conditionally format the duplicates in Columns 2 and 3 (again, for each like value in Column 1).
    I still can't figure out what you're trying to do...

    Search column 1 for like values... Does that mean ONLY in column 1, so if there are 10 duplicates in column 2, but only 1 occurance in column one, then ignore/continue?

    Examine columns 2 and 3 for duplicate values... Does that mean duplicates between column 2 and 3, or within only 2, then within only 3, or is it duplicates of the values that were duplicates in column 1?

    Format the duplicates in columns 2 and 3 (again, for each like value in column 1). So we're not doing anything to column one, we're only formatting columns 2 and three dependant upon... whatever it's dependant upon?

    Would you be able to post an example of your expected results if you were to do this manually? Posting a workbook with nothing in it but data, leaves us guessing multiple times with code variations until we happen to get what you want.

    Oh, and an observation:
    I assumed it was borrowed from a web site
    You do know that people create websites right? So if it's on a website, it's made by a person? You'll likely find code written by various people who frequent this site on "Websites".
    Last edited by mewingkitty; 03-21-2009 at 04:24 PM.
    =IF(AND(OR(BLONDE,BRUNETTE,REDHEAD),OR(MY PLACE,HER PLACE),ME),BOW-CHICKA-BOW-WOW,ANOTHER NIGHT ON THE INTERNET)

+ 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