Skip to content

Instantly share code, notes, and snippets.

@ateneva
Last active April 18, 2018 08:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ateneva/2c5b979c0bedb3d38258ebe76d1a0af9 to your computer and use it in GitHub Desktop.
Save ateneva/2c5b979c0bedb3d38258ebe76d1a0af9 to your computer and use it in GitHub Desktop.
Colour a range of cells if they meet a certain condition
Sub ColourCellsin_DifferentColumn()
Dim Cell As Range
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'written by Angelina Teneva, September 2016
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
For Each Cell In Range("F5:F" & ActiveSheet.UsedRange.Rows.Count)
Cell.Activate
Range(ActiveCell.Offset(0, -5), ActiveCell.Offset(0, 4)).Font.Color = RGB(0, 0, 0) 'black (reset any previous formatting)
If ActiveCell.Value > 10 Then Range(ActiveCell.Offset(0, -5), ActiveCell.Offset(0, 4)).Font.Color = RGB(255, 0, 0) 'red
Next Cell
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment