I have to do a simple operation from macro that it compares text in three columns and gives results using following logic in adjacent column :-
Column --> G H I ---> J
FC FC FC ---> FC
NC NC NC ---> NC
Else
result in J should be PC.
Also, if F = FC, color cell with Green, If F=NC, color cell Red and else if its PC color cell Blue.
I tried to write a code and but while compilation it shows some error. I think there is some error in the code lines where I have applied "And" operation.
Could any one help me in correcting the code.
Thanks is advance !!
LastRow = Range("A" & Rows.Count).End(xlUp).Row
For RowNo = 2 To LastRow
If Cells(RowNo, "G") And Cells(RowNo, "H") And Cells(RowNo, "I") = "FC" Then
strCompliance = "FC"
ElseIf Cells(RowNo, "G") And Cells(RowNo, "H") And Cells(RowNo, "I") = "NC" Then
strCompliance = "NC"
Else
strCompliance = "PC"
End If
With Cells(RowNo, "J")
.Value = strCompliance
.Font.Bold = True
If Cells(RowNo, "J") = "FC" Then
Cells(RowNo, "J").Interior.Color = RGB(0, 255, 0)
ElseIf Cells(RowNo, "J") = "NC" Then
Cells(RowNo, "J").Interior.Color = RGB(255, 0, 0)
ElseIf Cells(RowNo, "J") = "PC" Then
Cells(RowNo, "J").Interior.Color = RGB(0, 0, 255)
End If
End With
Bookmarks