Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #4  
Old 07-27-2011, 04:45 AM
Catalin.B Catalin.B is offline Conditional color fill based on presence of data Windows Vista Conditional color fill based on presence of data Office 2007
Expert
 
Join Date: May 2011
Location: Iaşi, Romānia
Posts: 386
Catalin.B is on a distinguished road
Default

Avanderh, you have two ways to do this:
with conditional formatting: in this case, you need two rules for every category, because you have 2 ranges : first is column D and second from H to Q
a rule vill apply to this range:
=$D$12:$D$100, and the formula to format is:
=$D12="Post-Proposal"; this rule will take care of column D
the second rule for this category will apply to range =$H$12:$Q$100, and the formula to format is: =AND($D12="Post-Proposal";H12>0)
for other categories, just enter new rule and apply to same ranges, you will only change "Post-Proposal" to "Whatever"
the second way, is to use a macro:

Sub ColorIndex()
Dim planWks As Worksheet
Dim nextRow As Long
Set planWks = Worksheets("Foaie1")
Dim i As Integer
Dim j As Integer

Dim r1, r2 As Range
Application.ScreenUpdating = False

For i = 12 To 300
Set r1 = planWks.Cells(i, "D")
For j = 8 To 17
If r1.Value = "Proposal" Then
r1.Interior.ColorIndex = 39
planWks.Cells(i, j).Interior.ColorIndex = 39
End If

If planWks.Cells(i, j).Value = 0 Then
planWks.Cells(i, j).Interior.ColorIndex = xlNone
End If
Next j
Next i

For i = 12 To 300
Set r1 = planWks.Cells(i, "D")
For j = 8 To 17
If r1.Value = "Post-Proposal" Then
r1.Interior.ColorIndex = 25
planWks.Cells(i, j).Interior.ColorIndex = 25
End If

If planWks.Cells(i, j).Value = 0 Then
planWks.Cells(i, j).Interior.ColorIndex = xlNone
End If
Next j
Next i


For i = 12 To 300
Set r1 = planWks.Cells(i, "D")
For j = 8 To 17
If r1.Value = "other" Then
r1.Interior.ColorIndex = 27
planWks.Cells(i, j).Interior.ColorIndex = 27
End If

If planWks.Cells(i, j).Value = 0 Then
planWks.Cells(i, j).Interior.ColorIndex = xlNone
End If
Next j
Next i


Application.ScreenUpdating = True
End Sub

You will find attached samples for both methods, but in my opinion, using conditional formatting is your best choice
Attached Files
File Type: xlsm sample2-conditional formatting.xlsm (19.4 KB, 24 views)
File Type: xlsm sample-formatting with macro.xlsm (27.7 KB, 17 views)
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
How can I fill the below emty cells with above cell data? Learner7 Excel 8 06-28-2011 12:10 PM
Conditional color fill based on presence of data Conditional data validation (list drop-down) click4akshay Excel 2 04-28-2011 01:51 PM
How can I fill cell color starting from Cell D5 using Conditional formatting instead Learner7 Excel 0 07-08-2010 05:50 AM
Conditional color fill based on presence of data Conditional Expression that Moves Data (challenging) themangoagent Excel 1 02-20-2010 11:29 AM
Conditional color fill based on presence of data Change Automatic Fill Color Leanne PowerPoint 1 11-04-2009 08:34 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 01:32 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft