PDA

View Full Version : [SOLVED:] Check value based on cell text and turn another cell Green if there is a match



sharc316
05-01-2017, 06:29 PM
Hi,

I'm looking for a quick way to reconcile the accuracy of VBA formatting by matching totals from VBA extracted sheets to statement total.

Basically would like to look for a value in column A "Total" then depending on which row this text is in would like to compare the number in Column N to the number in cell A3. The A3 cell is static and won't change, meaning the value will always be in that cell.

If the number from column N matches the number in cell A3 then would like A3 highlighted in green. If it does not match, then highlight A3 in red.

Thank you for your help.

SamT
05-01-2017, 07:45 PM
depending on which row this text is in would like to compare the number in Column N
Please explain what that means

I am guessing a one to one correlation

Sub SamT()

If Range("N" & Range("A:A").Find("Total").Row) = Range("A3") Then
Range("A3").Interior.ColorIndex = ??? 'See next code to find colorindex of green
Else
Range("A3").Interior.ColorIndex = 4
End If
End Sub


Sub ShowIndexColors()
'Run on empty sheet
Dim i as long

With ActiveSheet
For i = 1 to 56
With .Cells(i, "A")
.Value = i
.Interior.ColorIndex = i
End With
Next
End With
End Sub

sharc316
05-03-2017, 10:48 AM
Thank you SamT. The below code worked for me!


Sub SamT()

If Range("N" & Range("A:A").Find("Total").Row) = Range("A3") Then
Range("A3").Interior.ColorIndex = 4 'See next code to find colorindex of green
Else
Range("A3").Interior.ColorIndex = 3
End If
End Sub