Here I am providing you code for conditional coloring of excel cell. This example contains data of Sales Executive,Sales Target and Target Achieved. On clicking on Achiever's List data cells containing more than 90% sales target achieved will be colored.
VBA Code for this as Follows:
Sub selcellbyValue()
Dim salesRange, targetRange As Range
Dim salach, target As Integer
Set salesRange = Application.InputBox("Select Range", "Salesachieved Range", Type:=8)
tempval = 1
For Each cell In salesRange
If cell.Offset(1, 0).Value <> "" Then
salach = cell.Offset(1, 0).Value
target = cell.Offset(1, -1).Value
If (salach / target) > 0.9 Then
cell.Offset(1, 0).Interior.Color = RGB(321, 172, 118)
End If
End If
Next cell
End Sub
No comments:
Post a Comment