Solved

Excel 2007, conditional formatting cells based on if function

Posted on 2010-11-17
10
723 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
[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
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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
 
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
multiple unique values in different columns 15 37
LOOK FOR 22 34
copy down array 24 36
Excel Index/Match issue 4 22
How to quickly and accurately populate Word documents with Excel data, charts and images (including Automated Bookmark generation) David Miller (dlmille) Synopsis In this article you’ll learn how to use ExcelToWord! to copy data,charts, shapes …
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

710 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