Hello, I am trying to piece together code that I've stumbled upon, but cannot get this to work...
I need to be able to set a particular background color for a column of cells based on values in other adjacent cells in the same row.
The values that are being evaluated are percentage values (the format is XX%). The limit can change, and is located in column -6, and looks like this: >= 95%. I'm using the RIGHT function to attempt to only grab the first 3 characters from the right: 95%.
I have a very basic understanding of programming, and don't really know VBA at all... I'm sure there are plenty of mistakes with my syntax, since I can't compile this.
Any help would be appreciated.
Thank you in advance
Private Sub Worksheet_Change()
Dim icolor As Integer
Dim limit As Integer
Dim Target As Range
For Each cell In (Target, Range("H1:H110"))
limit = "=Value(RIGHT(R[0]C[-6],3))"
If Target.Offset(0, -4).Value >= limit And Target.Offset(0, -1).Value < limit Then
icolor = 6 'yellow if trending positive
End If
If Target.Offset(0, -1).Value >= limit Then
icolor = 4 'green if positive result
End If
If Target.Offset(0, -1).Value < limit And Target.Offset(0, -4).Value < limit Then
icolor = 3 'red if Failing and not trending positive
End If
If Target.Offset(0, -1).Value = "N/A" Then
icolor = 2 'white if Not applicable
End If
Target.Interior.ColorIndex = icolor
Next
End Sub
Bookmarks