You can run it automatically each time the workbook is open. Put this code
in the ThisWorkbook sheet (module):
Sub Workbook_Open
Call cFormat
end sub
OR (and I'll leave to work it out!) you could add a button to the form which
calls the macro. HINT_ click the Forms toolbar and select button control. In
the Assign Macro form select CFormat then OK.
FYI
Attached code clears ONLY colurs used in this worksheet:
Sub CFormat()
'
Dim rng As Range, cell As Range
Dim ncol As Integer, lrow As Long
Dim pcnt As Double, divisor As Double
ThisWorkbook.Worksheets("Sheet1").Activate ' <=== Change to your w/sheet
' Find column for current Month (add 5 to start in colum F onwards)
ncol = Application.Match(Range("A2"), Range("F3:q3"), 0) + 5
' Find last row of data in column A
lrow = Cells(Rows.Count, 1).End(xlUp).Row
' Clear colours used in this macro
Set rng = Range("F9:Q1" & lrow)
For Each cell In rng
Select Case cell.Interior.ColorIndex
Case Is = 4, 35, 36, 7, 54, 3
cell.Interior.ColorIndex = xlNone
End Select
Next cell
' Set range to cells for current month starting row 9
Set rng = Range(Cells(9, ncol), Cells(lrow, ncol))
' Set Divisor for current month
divisor = Cells(5, ncol)
' Loop through all cells in range
For Each cell In rng
' Check length of cell in column A
If Len(cell.Offset(0, -(ncol - 1))) = 4 Then
' Calculate perecentage
If Application.IsNumber(cell) Then ' Is this cell a number ?
pcnt = (cell / divisor) * 100
cell.Select
' Set colorindex based on percentage
Select Case pcnt
Case Is > 100
Selection.Interior.ColorIndex = 4
Case Is >= 90
Selection.Interior.ColorIndex = 35
Case Is >= 80
Selection.Interior.ColorIndex = 36
Case Is >= 70
Selection.Interior.ColorIndex = 7
Case Is >= 1
Selection.Interior.ColorIndex = 54
Case Else
Selection.Interior.ColorIndex = 3
End Select
Else
cell.Select
Selection.Interior.ColorIndex = 3
End If
End If
Next cell
End Sub