jonofisher
Board Regular
- Joined
- May 25, 2005
- Messages
- 51
Hello
I would like to conditional format some cells. Since there are more than 3 cases, i understand i need to use VBA. It gets tricky because I want to incorporate a vlookup in there somehow. the code runs but doesn't seem to work.
any help would be really, really appreciated. thanks heaps
The code i have written so far is:
I would like to conditional format some cells. Since there are more than 3 cases, i understand i need to use VBA. It gets tricky because I want to incorporate a vlookup in there somehow. the code runs but doesn't seem to work.
any help would be really, really appreciated. thanks heaps
The code i have written so far is:
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim Cell As Range
Dim Rng1 As Range
'range of the cells that i want to conditioanl format
Set Rng1 = Range("b3:au55")
If Rng1 Is Nothing Then
Set Rng1 = Range(Target.Address)
Else
Set Rng1 = Union(Range(Target.Address), Rng1)
For Each Cell In Rng1
On Error Resume Next
'i want to lookup the values in the conditional format range in a list in
'f57:t731 and then format based on the outcomes of the 15th column
Set Lookup = Application.WorksheetFunction.VLookup(ActiveCell, "$f$57:$t$731", "15", "FALSE")
'trying to format based on lookup result here:
Select Case Lookup.Value
Case ""
ActiveCell.Interior.ColorIndex = xlNone
AtivellCell.Font.Bold = False
Case "Asset Services"
ActiveCell.Interior.ColorIndex = 3
Cell.Font.Bold = False
Case "Business Services"
ActiveCell.Interior.ColorIndex = 4
Cell.Font.Bold = False
Case "Business Strategy"
Cell.Interior.ColorIndex = 5
Cell.Font.Bold = False
Case "Operations"
Cell.Interior.ColorIndex = 6
Cell.Font.Bold = False
Case "Corporate Legal"
Cell.Interior.ColorIndex = 7
Cell.Font.Bold = False
Case "HR"
Cell.Interior.ColorIndex = 8
Cell.Font.Bold = False
Case "Program Management"
Cell.Interior.ColorIndex = 9
Cell.Font.Bold = False
Case "Regulation"
Cell.Interior.ColorIndex = 10
Cell.Font.Bold = False
Case "Asset Owner Interface"
Cell.Interior.ColorIndex = 11
Cell.Font.Bold = False
Case "General Management"
Cell.Interior.ColorIndex = 12
Cell.Font.Bold = False
Case "Internal Audit"
Cell.Interior.ColorIndex = 13
Cell.Font.Bold = False
Case "Corporate Finance"
Cell.Interior.ColorIndex = 14
Cell.Font.Bold = False
Case "Aam Finance"
Cell.Interior.ColorIndex = 15
Cell.Font.Bold = False
Case "Alinta Corporate"
Cell.Interior.ColorIndex = 16
Cell.Font.Bold = False
Case "APS"
Cell.Interior.ColorIndex = 17
Cell.Font.Bold = False
Case "AIH"
Cell.Interior.ColorIndex = 18
Cell.Font.Bold = False
Case Else
Cell.Interior.ColorIndex = xlNone
Cell.Font.Bold = False
End Select
Next
End If
End Sub