+ Reply to Thread
Results 1 to 6 of 6

Comparing data.

  1. #1
    Registered User
    Join Date
    04-03-2008
    Posts
    9

    Comparing data.

    I have a range of data in cells E5 to H51. I would like to run a macro to compare the data all of these cells and highlight the cells which have the same data. Is there a way I can do this??? The End of the data range changes everytime new data is added to it..

  2. #2
    Forum Expert
    Join Date
    12-29-2004
    Location
    Michigan, USA
    MS-Off Ver
    2013
    Posts
    2,208
    Rather than running a macro, what about conditional formatting?

    Starting with cell E5, select E5:H51.

    Format > Conditional Formatting

    Select Formula Is from the drop-down, and type:

    =COUNTIF($E$5:$H$51,E5)>1

    Then select the cell pattern color you wish.

    HTH

    Jason

    Edit: Whoops, I just saw that the data changes all the time. Another option is rather than using $E$5:$H$51, use a dynamic named range, then use that name in the formula. For example:

    =COUNTIF(MyRange,E5)>1

    Here is a description of dynamic named ranges:

    http://www.ozgrid.com/Excel/DynamicRanges.htm
    http://www.cpearson.com/excel/named.htm
    http://www.contextures.com/xlNames01.html

    HTH

    Jason
    Last edited by jasoncw; 06-05-2008 at 08:23 AM.

  3. #3
    Registered User
    Join Date
    04-03-2008
    Posts
    9

    Comparing...

    Wow... That was simple... It works... Thanks so much...

  4. #4
    Forum Expert
    Join Date
    12-29-2004
    Location
    Michigan, USA
    MS-Off Ver
    2013
    Posts
    2,208
    Glad it helped.

    Jason

  5. #5
    Registered User
    Join Date
    04-03-2008
    Posts
    9

    Unhappy

    I have another question along the same lines. Is there any formula I can use in conditional formatting where all the cell which have data consisting of the same 3 to 4 characters at the beginning? Eg. A1 to A38 may have a few cells which could have "PPSS" as the first 4 characters followed 2 characters (which are variable). Is there any way the cells containing PPSS* (* for the remaining 2 variable characters) can be highlighted?

  6. #6
    Forum Expert
    Join Date
    12-29-2004
    Location
    Michigan, USA
    MS-Off Ver
    2013
    Posts
    2,208
    Hi, Judy.

    If you only are looking for cells where the left 4 characters are "PPSS", you could use:

    =LEFT(A1,4)="PPSS"

    Or if you need the above, and it needs to be 6 characters in length, you could use:

    =AND(LEFT(A1,4)="PPSS",LEN(A1)=6)

    HTH

    Jason

+ 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. Various macro issues linked to DDE
    By JMann in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 05-16-2008, 08:08 AM
  2. Comparing and isolating data in lists...
    By firefiend in forum Excel General
    Replies: 1
    Last Post: 05-16-2007, 10:50 AM
  3. Unlinking Imported Data
    By Donquick in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-15-2007, 09:29 AM
  4. Replies: 3
    Last Post: 05-12-2007, 08:12 AM
  5. Comparing Data
    By pberry5682 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 05-10-2007, 05:59 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