Solved

Excel 2007, conditional formatting cells based on if function

Posted on 2010-11-17
10
687 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
Comment Utility
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
Comment Utility
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
Comment Utility
slow fingers :)
0
 
LVL 22

Expert Comment

by:spattewar
Comment Utility
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
Comment Utility
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
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
LVL 24

Expert Comment

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

Expert Comment

by:GlobaLevel
Comment Utility
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
Comment Utility
sorry ....MatthewsPatrick
0
 

Author Comment

by:Laura Sheldon
Comment Utility
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
Comment Utility
Y'all are the best! Thanks for the help!
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Dealing with unintended Excel Active-X resizing quirks (VBA code simulates "self correction") David Miller (dlmille) Intro Not everyone is a fan of Active-X controls in spreadsheets (as opposed to the UserForm approach, the older Form controls …
Drop Down List with Unique/Distinct Values (Part II - ComboBox or ListBox and Data Validation List Bonus!) David Miller (dlmille) Intro This article focuses on delivering unique, sorted lists to list objects (e.g., ComboBox, ListBox) and Dat…
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 …
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …

772 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

16 Experts available now in Live!

Get 1:1 Help Now