I have used the following code to format the cells in my spreadsheet. I copied this from a website so I don't actually know what it means! It's working fine but I would like to be able to format by the first three letters in each cell, not just the first letter. I am a complete novice and any help would be hugely appreciated.
Thanks in advance
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
Dim vLetter As String
Dim vColor As Long
Dim cRange As Range
Dim cell As Range
Set cRange = Intersect(Range("A17:A65000"), Range(Target(1).Address))
If cRange Is Nothing Then Exit Sub
For Each cell In Target
vLetter = UCase(Left(cell.Value & " ", 1))
vColor = 0
Select Case vLetter
Case "T"
vColor = 34
Case "P"
vColor = 37
Case "G"
vColor = 39
Case "M"
vColor = 38
Case "C"
vColor = 40
Case "A"
vColor = 36
End Select
Application.EnableEvents = False
cell.Interior.ColorIndex = vColor
Application.EnableEvents = True
Next cell
End Sub
Bookmarks