Option Explicit
Private Sub ComboBox1_Change()
Worksheets("CLO Print").Range("C8:C54").Select
Selection.Interior.ColorIndex = xlAutomatic
Selection.Font.ColorIndex = xlAutomatic
Application.ScreenUpdating = False
'The following lines of code are necessary to activate the 'on change' macro (at bottom here)
'which sets the cells interior colours and font relevant to the code number entered.
'Other column formulae are in held in cells.
'Column numbers are related to Data Sheet from Column A (C158 = column FB)
ActiveSheet.Range("D8").Select
ActiveCell.FormulaR1C1 = "=VLOOKUP(R5C3,'Data Sheet'!R15C6:R145C158,13)"
ActiveSheet.Range("D9").Select
ActiveCell.FormulaR1C1 = "=VLOOKUP(R5C3,'Data Sheet'!R15C6:R145C158,16)"
ActiveSheet.Range("D10").Select
ActiveCell.FormulaR1C1 = "=VLOOKUP(R5C3,'Data Sheet'!R15C6:R145C158,19)"
ActiveSheet.Range("D11").Select
ActiveCell.FormulaR1C1 = "=VLOOKUP(R5C3,'Data Sheet'!R15C6:R145C158,22)"
ActiveSheet.Range("D12").Select
ActiveCell.FormulaR1C1 = "=VLOOKUP(R5C3,'Data Sheet'!R15C6:R145C158,25)"
ActiveSheet.Range("D13").Select
ActiveCell.FormulaR1C1 = "=VLOOKUP(R5C3,'Data Sheet'!R15C6:R145C158,28)"
ActiveSheet.Range("D14").Select
ActiveCell.FormulaR1C1 = "=VLOOKUP(R5C3,'Data Sheet'!R15C6:R145C158,31)"
ActiveSheet.Range("D15").Select
ActiveCell.FormulaR1C1 = "=VLOOKUP(R5C3,'Data Sheet'!R15C6:R145C158,34)"
ActiveSheet.Range("D16").Select
ActiveCell.FormulaR1C1 = "=VLOOKUP(R5C3,'Data Sheet'!R15C6:R145C158,37)"
ActiveSheet.Range("D17").Select
ActiveCell.FormulaR1C1 = "=VLOOKUP(R5C3,'Data Sheet'!R15C6:R145C158,40)"
ActiveSheet.Range("D18").Select
ActiveCell.FormulaR1C1 = "=VLOOKUP(R5C3,'Data Sheet'!R15C6:R145C158,43)"
ActiveSheet.Range("D19").Select
ActiveCell.FormulaR1C1 = "=VLOOKUP(R5C3,'Data Sheet'!R15C6:R145C158,46)"
ActiveSheet.Range("D20").Select
ActiveCell.FormulaR1C1 = "=VLOOKUP(R5C3,'Data Sheet'!R15C6:R145C158,49)"
ActiveSheet.Range("D21").Select
ActiveCell.FormulaR1C1 = "=VLOOKUP(R5C3,'Data Sheet'!R15C6:R145C158,52)"
ActiveSheet.Range("D22").Select
ActiveCell.FormulaR1C1 = "=VLOOKUP(R5C3,'Data Sheet'!R15C6:R145C158,55)"
ActiveSheet.Range("D23").Select
ActiveCell.FormulaR1C1 = "=VLOOKUP(R5C3,'Data Sheet'!R15C6:R145C158,58)"
ActiveSheet.Range("D24").Select
ActiveCell.FormulaR1C1 = "=VLOOKUP(R5C3,'Data Sheet'!R15C6:R145C158,61)"
ActiveSheet.Range("D25").Select
ActiveCell.FormulaR1C1 = "=VLOOKUP(R5C3,'Data Sheet'!R15C6:R145C158,64)"
ActiveSheet.Range("D26").Select
ActiveCell.FormulaR1C1 = "=VLOOKUP(R5C3,'Data Sheet'!R15C6:R145C158,67)"
ActiveSheet.Range("D27").Select
ActiveCell.FormulaR1C1 = "=VLOOKUP(R5C3,'Data Sheet'!R15C6:R145C158,70)"
ActiveSheet.Range("D28").Select
ActiveCell.FormulaR1C1 = "=VLOOKUP(R5C3,'Data Sheet'!R15C6:R145C158,73)"
ActiveSheet.Range("D29").Select
ActiveCell.FormulaR1C1 = "=VLOOKUP(R5C3,'Data Sheet'!R15C6:R145C158,76)"
ActiveSheet.Range("D30").Select
ActiveCell.FormulaR1C1 = "=VLOOKUP(R5C3,'Data Sheet'!R15C6:R145C158,79)"
ActiveSheet.Range("D31").Select
ActiveCell.FormulaR1C1 = "=VLOOKUP(R5C3,'Data Sheet'!R15C6:R145C158,82)"
ActiveSheet.Range("D32").Select
ActiveCell.FormulaR1C1 = "=VLOOKUP(R5C3,'Data Sheet'!R15C6:R145C158,85)"
ActiveSheet.Range("D33").Select
ActiveCell.FormulaR1C1 = "=VLOOKUP(R5C3,'Data Sheet'!R15C6:R145C158,88)"
ActiveSheet.Range("D34").Select
ActiveCell.FormulaR1C1 = "=VLOOKUP(R5C3,'Data Sheet'!R15C6:R145C158,91)"
ActiveSheet.Range("D35").Select
ActiveCell.FormulaR1C1 = "=VLOOKUP(R5C3,'Data Sheet'!R15C6:R145C158,94)"
ActiveSheet.Range("D36").Select
ActiveCell.FormulaR1C1 = "=VLOOKUP(R5C3,'Data Sheet'!R15C6:R145C158,97)"
ActiveSheet.Range("D37").Select
ActiveCell.FormulaR1C1 = "=VLOOKUP(R5C3,'Data Sheet'!R15C6:R145C158,100)"
ActiveSheet.Range("D38").Select
ActiveCell.FormulaR1C1 = "=VLOOKUP(R5C3,'Data Sheet'!R15C6:R145C158,103)"
ActiveSheet.Range("D39").Select
ActiveCell.FormulaR1C1 = "=VLOOKUP(R5C3,'Data Sheet'!R15C6:R145C158,106)"
ActiveSheet.Range("D40").Select
ActiveCell.FormulaR1C1 = "=VLOOKUP(R5C3,'Data Sheet'!R15C6:R145C158,109)"
ActiveSheet.Range("D41").Select
ActiveCell.FormulaR1C1 = "=VLOOKUP(R5C3,'Data Sheet'!R15C6:R145C158,112)"
ActiveSheet.Range("D42").Select
ActiveCell.FormulaR1C1 = "=VLOOKUP(R5C3,'Data Sheet'!R15C6:R145C158,115)"
ActiveSheet.Range("D43").Select
ActiveCell.FormulaR1C1 = "=VLOOKUP(R5C3,'Data Sheet'!R15C6:R145C158,118)"
ActiveSheet.Range("D44").Select
ActiveCell.FormulaR1C1 = "=VLOOKUP(R5C3,'Data Sheet'!R15C6:R145C158,121)"
ActiveSheet.Range("D45").Select
ActiveCell.FormulaR1C1 = "=VLOOKUP(R5C3,'Data Sheet'!R15C6:R145C158,124)"
ActiveSheet.Range("D46").Select
ActiveCell.FormulaR1C1 = "=VLOOKUP(R5C3,'Data Sheet'!R15C6:R145C158,127)"
ActiveSheet.Range("D47").Select
ActiveCell.FormulaR1C1 = "=VLOOKUP(R5C3,'Data Sheet'!R15C6:R145C158,130)"
ActiveSheet.Range("D48").Select
ActiveCell.FormulaR1C1 = "=VLOOKUP(R5C3,'Data Sheet'!R15C6:R145C158,133)"
ActiveSheet.Range("D49").Select
ActiveCell.FormulaR1C1 = "=VLOOKUP(R5C3,'Data Sheet'!R15C6:R145C158,136)"
ActiveSheet.Range("D50").Select
ActiveCell.FormulaR1C1 = "=VLOOKUP(R5C3,'Data Sheet'!R15C6:R145C158,139)"
ActiveSheet.Range("D51").Select
ActiveCell.FormulaR1C1 = "=VLOOKUP(R5C3,'Data Sheet'!R15C6:R145C158,142)"
ActiveSheet.Range("D52").Select
ActiveCell.FormulaR1C1 = "=VLOOKUP(R5C3,'Data Sheet'!R15C6:R145C158,145)"
ActiveSheet.Range("D53").Select
ActiveCell.FormulaR1C1 = "=VLOOKUP(R5C3,'Data Sheet'!R15C6:R145C158,148)"
ActiveSheet.Range("D54").Select
ActiveCell.FormulaR1C1 = "=VLOOKUP(R5C3,'Data Sheet'!R15C6:R145C158,151)"
ActiveSheet.Range("D55").Select
Application.ScreenUpdating = True
ActiveSheet.Range("A1").Select
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
Application.ScreenUpdating = False
' This code checks for a change of Status in the Current Status column (D) and
' on change sets cells 'interior' and 'font ' colours according to table "rCodes".
' The range covered extends from column ‘A’ (first Status column), to column ‘D’ (Current Status Column).
If Target.Count > 1 Then Exit Sub
Dim rCell As Range
Dim rCodes As Range
Dim rRow As Range
Dim vMatch
Dim LastRow As Long
LastRow = Range("A65536").End(xlUp).Row
Set rCodes = Range("g6:g16")
If (Target.Column >= 1) And (Target.Column <= Range("D1").Column) And (Target.Row <= LastRow) Then
If Len(Target.Value) > 0 Then
On Error Resume Next
vMatch = Application.Match(Target.Value, rCodes, 0)
If IsError(vMatch) Then
'DO NOTHING
Else
With Target.Cells
.Offset(0, -1).Interior.Color = rCodes.Cells(vMatch).Interior.Color
.Offset(0, -1).Font.Color = rCodes.Cells(vMatch).Font.Color
End With
End If
End If
End If
Application.ScreenUpdating = True
End Sub