?
Solved

Trouble with Excel Array Formulas + Conditional Formatting

Posted on 2003-03-29
6
Medium Priority
?
335 Views
Last Modified: 2012-06-27
I want to compare a range of cells with other ranges of cells and do a conditional format based on the result.  Here is an example of what I'm asking:

Name1   A   B   C   D
Name2   B   A   C   D
Name3   A   B   D   C
Name4   A   B   C   D

I want to make the background of the Name1 cell blue, becasue the text values in the following cells {A,B,C,D} match those for Name4.  Likewise Name4 cell background should turn blue, because its following values match those of Name1.  If a Name had a unique sequence of text values following it (e.g. Name2 and Name3), the cell background would remain at the default colour.

I have 54 names in total and have tried a lot of different formulas, but I'm not an Excel expert and maybe this is a simple problem for someone out there.  Any help would be greatly appreciated.  Thanks!!
0
Comment
Question by:cawleym
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 13

Expert Comment

by:cri
ID: 8233405
My gut feeling: Using array formulas + conditional formatting is too complicated in your case (should it work at all). A work-around could be much simpler. Therefore:

a) Is the purpose to identify duplicates regarding columns 2,3,4,5 ?
b) Is using an auxiliary column acceptable ?
c) Will the number of rows increase in the future ?
 

0
 
LVL 3

Expert Comment

by:Moliere
ID: 8235125
I think this requires a macro like the following. I assume that you have the data in A1:E5 with a header in the first row. Correct me if I am wrong.

Sub HighlightDupes()
Dim AreaRange As Range, ARRows As Integer
    Set AreaRange = Range(Cells(1, 1), Cells(1, 1).End(xlDown).Offset(0, 4))
    ARRows = AreaRange.Rows.Count
    AreaRange.Sort Key1:=Range("E1"), Key2:=Range("D1"), Header:=xlYes
    AreaRange.Sort Key1:=Range("C1"), Key2:=Range("B1"), Header:=xlYes
   
    Range(Cells(2, 6), Cells(1, 6).Offset(ARRows - 1, 0)).FormulaR1C1 = "=OR(AND(RC2=R[-1]C2,RC3=R[-1]C3,RC4=R[-1]C4,RC5=R[-1]C5),AND(RC2=R[1]C2,RC3=R[1]C3,RC4=R[1]C4,RC5=R[1]C5))"
    For i = 2 To ARRows
        If Cells(i, 6) Then
            With Cells(i, 1).Interior
                .ColorIndex = 34
                .Pattern = xlSolid
            End With
        End If
    Next i
   
    Columns(6).Delete
    AreaRange.Sort Key1:=Range("A1"), Header:=xlYes
End Sub
0
 

Author Comment

by:cawleym
ID: 8235317
Cri and Moliere ... thanks for your comments.

Cri:
a) the purpose is to identify rows which have duplicate data in columns 2-8 (B-H), though my example didn't show that much.
b) an auxiliary column is definitely acceptable.
c) no. the number of rows is fixed.

Moliere:
The data is in B6:H59.  Will the macro be able to handle that much data?
0
Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

 
LVL 1

Accepted Solution

by:
iaminit earned 375 total points
ID: 8235780
This may not be the slickest answer, but ...
you could add a column (e.g., column I) that concatenates columns B through H -- i.e., =B6&C6&D6&E6&F6&G6&H6.  And copy that to all the rows.  Then add the conditional format to cell A6 --
=COUNTIF($I$6:$I$59,I6)>1
Even better would be to name the range I6:I59 and use the range name in the conditional format just in case you need to expand your range down the road.
0
 
LVL 13

Expert Comment

by:cri
ID: 8236441
cawleym, iaminit's solution is one of the two I would have suggested. If you want to get rid of the duplicates I would have suggested to sort the range, first using the concatenated column to group the duplicates, delete them manually, and then resort in the required order (perhaps using a previously added ranking column)
0
 

Author Comment

by:cawleym
ID: 8244058
Hi Iaminit ... thanks for the solution!  I know it's not the slickest answer but it does the job.

Thanks also cri and moliere for your earlier suggestions.
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In our personal lives, we have well-designed consumer apps to delight us and make even the most complex transactions simple. Many enterprise applications, however, are a bit behind the times. For an enterprise app to be successful in today's tech wo…
The article will include the best Data Recovery Tools along with their Features, Capabilities, and their Download Links. Hope you’ll enjoy it and will choose the one as required by you.
The viewer will learn how to successfully download and install the SARDU utility on Windows 7, without downloading adware.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question