Solved

Excel 2007, conditional formatting cells based on if function

Posted on 2010-11-17
10
713 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
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Workbook link problems after copying tabs to a new workbook? David Miller (dlmille) Intro Have you either copied sheets to a new workbook, and after having saved and opened that workbook, you find that there are links back to the original sou…
Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

828 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