Logo 
Search:

MS Office Answers

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds
  Question Asked By: Anita Morales   on Feb 25 In MS Office Category.

  
Question Answered By: Geb Chalthoum    on Feb 25

Something like this will work...

Option Explicit

Sub Conditional_Shading()
Dim cl As Range
Dim RNG As Range
'get the last used cell of column  q
Set RNG = Columns("q").Find(What:="*", _
SearchDirection:=xlPrevious, _
SearchOrder:=xlByRows)
For Each cl In Range([Q1], [RNG])
If cl > 0 And cl <= 5 Then
With Cells(cl.Row, 1).Interior
Cells(cl.Row, 1).Select
Select Case cl.Value
Case Is = 5
.ColorIndex = 5 'Blue
Case Is = 4
.ColorIndex = 4 'Green
Case Is = 2
.ColorIndex = 3 'Red
Case Is = 1
.ColorIndex = 7 'Pink
End Select
'.Pattern = xlSolid
.Pattern = xlGray25
End With
End If
Next cl
End Sub

Share: 

 

This Question has 2 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on vba code help Or get search suggestion and latest updates.


Tagged: