Solved

Excel 2007, conditional formatting cells based on if function

Posted on 2010-11-17
10
699 Views
Last Modified: 2012-05-10
I'd like to know how to lay out the formula, if it's even possible, to use cond formatting to change the appearance of one set of cells based on the contents of another set of cells.

Using example spreadsheet, I want to recolor the cells to the right of the black line a different color, or bold them (doesn't matter how it's represented) based on whether the cells to the left of the black line are 0 or -1 (true or false result from exported DB query).

Thanks, Laura example-for-cond-formatting-1117.xlsx
0
Comment
Question by:Laura Sheldon
  • 3
  • 2
  • 2
  • +2
10 Comments
 
LVL 24

Expert Comment

by:StephenJR
ID: 34156275
Highlight from C2 all your data, then CF - formula =$A2=0 and select your formatting
0
 
LVL 92

Accepted Solution

by:
Patrick Matthews earned 375 total points
ID: 34156317
Yes.

1) Select c2:av149

2) Go to Manage Rules under Conditional Formatting

3) Add a rule using the formula =$A2=0 and choose your formatting

4) Add another rule using the formula =$A2=-1 and choose your formatting

Note the usage of the $ to fix an absolute reference.  This is critical :)
0
 
LVL 92

Expert Comment

by:Patrick Matthews
ID: 34156319
slow fingers :)
0
 
LVL 22

Expert Comment

by:spattewar
ID: 34156324
I have attached the modified file. check it.

I first applied the format to all the rows and then removed it from the first column.

Check the conditional formatting rules under conditional formatting menu under the home section.
example-for-cond-formatting-1117.xlsx
0
 
LVL 24

Assisted Solution

by:StephenJR
StephenJR earned 125 total points
ID: 34156332
You have to add a new rule for =$A2=-1 for the other values. See attachment - apologies for nasty colours.
example-for-cond-formatting-1117.xlsx
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 24

Expert Comment

by:StephenJR
ID: 34156345
Patrick - if you work out words per minute you were probably quicker than me ...
0
 
LVL 10

Expert Comment

by:GlobaLevel
ID: 34156604
These guys, including MatthewPatricks are the super experts...and I know you want a formula..but I can only offer vba...so if it helps...

If cell A1 id = -1 then it will search that row for a value and change to bkgrnd color to orange...otherwise next row and so on..if A1 = 0 ..then move on..
Function change_cells()



Dim i As Long

i = 1



For i = 1 To 65000 ' U



If Cells(i, "A").Value <> "" Then 'p

' IF -1 THEN WE ARE IN THE RED!!

If Cells(i, "A").Value = "-1" Then 'o





'FORMAT THE CELLS THAT SHOULD BE RED...

If Cells(i, "C").Value <> "" Then

  Cells(i, "C").Interior.ColorIndex = 45

Else: End If

'--

If Cells(i, "D").Value <> "" Then

  Cells(i, "D").Interior.ColorIndex = 45

Else: End If

'--

If Cells(i, "E").Value <> "" Then

  Cells(i, "E").Interior.ColorIndex = 45

Else: End If

'--

If Cells(i, "F").Value <> "" Then

  Cells(i, "F").Interior.ColorIndex = 45

Else: End If

'--

If Cells(i, "G").Value <> "" Then

  Cells(i, "G").Interior.ColorIndex = 45

Else: End If

'-

If Cells(i, "H").Value <> "" Then

  Cells(i, "H").Interior.ColorIndex = 45

Else: End If

'-

If Cells(i, "I").Value <> "" Then

  Cells(i, "I").Interior.ColorIndex = 45

Else: End If

'-

If Cells(i, "J").Value <> "" Then

  Cells(i, "J").Interior.ColorIndex = 45

Else: End If

'-

If Cells(i, "K").Value <> "" Then

  Cells(i, "K").Interior.ColorIndex = 45

Else: End If

'-

If Cells(i, "L").Value <> "" Then

  Cells(i, "L").Interior.ColorIndex = 45

Else: End If

'-

If Cells(i, "M").Value <> "" Then

  Cells(i, "M").Interior.ColorIndex = 45

Else: End If

'-

If Cells(i, "N").Value <> "" Then

  Cells(i, "N").Interior.ColorIndex = 45

Else: End If

'-

If Cells(i, "O").Value <> "" Then

  Cells(i, "O").Interior.ColorIndex = 45

Else: End If

'-

If Cells(i, "P").Value <> "" Then

  Cells(i, "P").Interior.ColorIndex = 45

Else: End If

'-

If Cells(i, "Q").Value <> "" Then

  Cells(i, "Q").Interior.ColorIndex = 45

Else: End If

'-

If Cells(i, "R").Value <> "" Then

  Cells(i, "R").Interior.ColorIndex = 45

Else: End If

'-

If Cells(i, "S").Value <> "" Then

  Cells(i, "S").Interior.ColorIndex = 45

Else: End If

'-

If Cells(i, "T").Value <> "" Then

  Cells(i, "T").Interior.ColorIndex = 45

Else: End If

'-

If Cells(i, "U").Value <> "" Then

  Cells(i, "U").Interior.ColorIndex = 45

Else: End If

'-

If Cells(i, "V").Value <> "" Then

  Cells(i, "V").Interior.ColorIndex = 45

Else: End If

'-

If Cells(i, "W").Value <> "" Then

  Cells(i, "W").Interior.ColorIndex = 45

Else: End If

'-

If Cells(i, "X").Value <> "" Then

  Cells(i, "X").Interior.ColorIndex = 45

Else: End If

'-

If Cells(i, "Y").Value <> "" Then

  Cells(i, "Y").Interior.ColorIndex = 45

Else: End If

'-

If Cells(i, "Z").Value <> "" Then

  Cells(i, "Z").Interior.ColorIndex = 45

Else: End If

'-

If Cells(i, "AA").Value <> "" Then

  Cells(i, "AA").Interior.ColorIndex = 45

Else: End If

'-

If Cells(i, "AB").Value <> "" Then

  Cells(i, "AB").Interior.ColorIndex = 45

Else: End If

'-

If Cells(i, "AC").Value <> "" Then

  Cells(i, "AC").Interior.ColorIndex = 45

Else: End If

'-

If Cells(i, "AD").Value <> "" Then

  Cells(i, "AD").Interior.ColorIndex = 45

Else: End If

'-

If Cells(i, "AE").Value <> "" Then

  Cells(i, "AE").Interior.ColorIndex = 45

Else: End If

'-

If Cells(i, "AF").Value <> "" Then

  Cells(i, "AF").Interior.ColorIndex = 45

Else: End If

'-

If Cells(i, "AG").Value <> "" Then

  Cells(i, "AG").Interior.ColorIndex = 45

Else: End If

'-

If Cells(i, "AH").Value <> "" Then

  Cells(i, "AH").Interior.ColorIndex = 45

Else: End If

'-

If Cells(i, "AI").Value <> "" Then

  Cells(i, "AI").Interior.ColorIndex = 45

Else: End If

'-

If Cells(i, "AJ").Value <> "" Then

  Cells(i, "AJ").Interior.ColorIndex = 45

Else: End If

'-

If Cells(i, "AK").Value <> "" Then

  Cells(i, "AK").Interior.ColorIndex = 45

Else: End If

'-

If Cells(i, "AL").Value <> "" Then

  Cells(i, "AL").Interior.ColorIndex = 45

Else: End If



'-

If Cells(i, "AM").Value <> "" Then

  Cells(i, "AM").Interior.ColorIndex = 45

Else: End If

'-

If Cells(i, "AN").Value <> "" Then

  Cells(i, "AN").Interior.ColorIndex = 45

Else: End If

'-

If Cells(i, "AO").Value <> "" Then

  Cells(i, "AO").Interior.ColorIndex = 45

Else: End If

'-

If Cells(i, "AP").Value <> "" Then

  Cells(i, "AP").Interior.ColorIndex = 45

Else: End If

'-

If Cells(i, "AQ").Value <> "" Then

  Cells(i, "AQ").Interior.ColorIndex = 45

Else: End If

'-

If Cells(i, "AR").Value <> "" Then

  Cells(i, "AR").Interior.ColorIndex = 45

Else: End If

'-

If Cells(i, "AS").Value <> "" Then

  Cells(i, "AS").Interior.ColorIndex = 45

Else: End If

'-

If Cells(i, "AT").Value <> "" Then

  Cells(i, "AT").Interior.ColorIndex = 45

Else: End If

'-

If Cells(i, "AU").Value <> "" Then

  Cells(i, "AU").Interior.ColorIndex = 45

Else: End If



'-

If Cells(i, "AV").Value <> "" Then

  Cells(i, "AV").Interior.ColorIndex = 45

Else: End If





Else 'O



End If 'O



Else 'P

  Exit For

End If 'P







Next ' U



MsgBox "Task Complete", vbOKOnly







End Function

Open in new window

0
 
LVL 10

Expert Comment

by:GlobaLevel
ID: 34156613
sorry ....MatthewsPatrick
0
 

Author Comment

by:Laura Sheldon
ID: 34156942
GlobaLevel: I'll give that a try in something else I'm trying I'm hoping it might work, but thanks for the input!
0
 

Author Closing Comment

by:Laura Sheldon
ID: 34156956
Y'all are the best! Thanks for the help!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
Approximate matching with VLOOKUP and MATCH seems to me to be a greatly under-used technique, and one which is vital for getting good performance out of large lookups. Until recently I would always have advised using an exact match for simplicity an…
The view will learn how to download and install SIMTOOLS and FORMLIST into Excel, how to use SIMTOOLS to generate a Monte Carlo simulation of 30 sales calls, and how to calculate the conditional probability based on the results of the Monte Carlo …
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…

920 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now