Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 41
Default Match values in more than one column

Hi

I have three columns of data and wish to highlight the matches or
change the format if there are any duplicates.

i.e

A B C

Apple Banana Cheese
Banana Orange Milk
Chocolate Milk Water
Biscuits Pear Bread
Wafers Plum Banana

So Banana would be highlighted in all, Milk in B and C. I assume I'd
use conditional formatting, but the MATCH function only seems to let
me compare against 1 column, not a full range.

Is there a simple way of doing this, or do I need some sort of
function to add together the matches and then conditional format?

If this can be done in VB that is fine as there is a script that
creates the lists so I could append to that.

Cheers

Rich


  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 913
Default Match values in more than one column

On Wed, 6 Jan 2010 04:30:09 -0800 (PST), Richhall
wrote:

Hi

I have three columns of data and wish to highlight the matches or
change the format if there are any duplicates.

i.e

A B C

Apple Banana Cheese
Banana Orange Milk
Chocolate Milk Water
Biscuits Pear Bread
Wafers Plum Banana

So Banana would be highlighted in all, Milk in B and C. I assume I'd
use conditional formatting, but the MATCH function only seems to let
me compare against 1 column, not a full range.

Is there a simple way of doing this, or do I need some sort of
function to add together the matches and then conditional format?

If this can be done in VB that is fine as there is a script that
creates the lists so I could append to that.

Cheers

Rich



If you have Excel 2007 this is easily achived by Conditional
Formatting that you find it in the Styles section of the Home tab.
Select the entire table then choose Conditional Formatting -
Highlight Cell Rules - Duplicate Values

Hope this helps / Lars-Åke
  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 41
Default Match values in more than one column

Unfortunately I am on Excel 2003 so unable to do it this way.

  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 913
Default Match values in more than one column

On Wed, 6 Jan 2010 05:06:36 -0800 (PST), Richhall
wrote:

Unfortunately I am on Excel 2003 so unable to do it this way.



Then try this macro:

Sub highlight_duplicates(r As Range)
For Each c1 In r
duplicate_found = False
For Each c2 In r
If (c1.Address < c2.Address) And c1.Value = c2.Value Then
duplicate_found = True
End If
Next c2
If duplicate_found Then
c1.Interior.ColorIndex = 3
Else
c1.Interior.ColorIndex = 0
End If
Next c1
End Sub


Sub test()
highlight_duplicates ActiveSheet.Range("A1:C5")
End Sub

Hope this helps / Lars-Åke
  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Max Max is offline
external usenet poster
 
Posts: 9,221
Default Match values in more than one column

Think COUNTIF will work over a rectangular range
Select the source range, which is assumed A1:C5 (with A1 active)
Apply CF, using Formula is: =COUNTIF($A$1:$C$5,A1)1
Format to taste OK out
(Banana & Milk will be triggered)
--
Max
Singapore
"Richhall" wrote in message
...
Unfortunately I am on Excel 2003 so unable to do it this way.





  #6   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 41
Default Match values in more than one column

Lars-Åke, thank you that worked brilliantly, amended slightly to put
in a longer script:

Dim r As Range

Set r = Worksheets("Sheet1").Range("DuplicateRange")

For Each c1 In r
duplicate_found = False
For Each c2 In r
If (c1.Address < c2.Address) And c1.Value = c2.Value Then
duplicate_found = True
End If
Next c2
If duplicate_found Then
c1.Font.Italic = True
c1.Font.Bold = True
Else
c1.Font.Italic = False
c1.Font.Bold = False
End If
Next c1

Max, thank you had already used Lars-Åkes post, so not tried that way.

  #7   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Max Max is offline
external usenet poster
 
Posts: 9,221
Default Match values in more than one column

Max, thank you had already used Lars-Åkes post, so not tried that way.

No problem. It doesn't take more than 10 seconds of your time to try that
option, though.
--
Max
Singapore


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
If two criteria match then sum matching values in another column Diddy Excel Worksheet Functions 5 February 25th 09 06:03 PM
match values in two column and return value in PW Excel Worksheet Functions 3 July 30th 08 06:52 PM
MATCH A NUMBER AS THE SUM OF VALUES IN A COLUMN Mau Excel Worksheet Functions 1 February 7th 07 12:09 PM
How to match values in one column to values in another? trib Excel Worksheet Functions 3 July 25th 06 08:30 AM
match 2 databases based on a column with same values jasonsgoat Excel Discussion (Misc queries) 0 April 4th 06 06:35 PM


All times are GMT +1. The time now is 11:21 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"