dreen
Board Regular
- Joined
- Nov 20, 2019
- Messages
- 52
I have two sheets and I am trying to re-apply the conditional formatting to Sheet 1 (Test 1) whenever a row is inserted into Row 2 of Sheet 1 (I have made my code apply the conditional formatting whenever Cell A2 is changed).
For the conditional formatting, I want to check if each visible cell in Column A Sheet 1 exists in Column A Sheet 2 with a Vlookup, and if it does then apply a Green conditional format to it.
I have two different codes I am trying to use in Sheet 1 ("Test 1") and both of them are applying the conditional format with the formulas, but none of the cells in Sheet 1 Column A are turning green when meeting the condition I
have set with the formula.
Here are both of my codes, I only need one to work, just different formulas:
And the second Formula I have also tried is:
Please Note, cross-posted with: Using VLookup with Conditional Formatting when Inserting a New Row
For the conditional formatting, I want to check if each visible cell in Column A Sheet 1 exists in Column A Sheet 2 with a Vlookup, and if it does then apply a Green conditional format to it.
I have two different codes I am trying to use in Sheet 1 ("Test 1") and both of them are applying the conditional format with the formulas, but none of the cells in Sheet 1 Column A are turning green when meeting the condition I
have set with the formula.
Here are both of my codes, I only need one to work, just different formulas:
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$A$2" Then
Dim lr As Long
lr = Range("A" & Sheet4.rows.Count).End(xlUp).Row
With Range("A2:A" & lr)
.FormatConditions.Delete
.FormatConditions.Add Type:=xlExpression, Formula1:="IF(ISLBANK(Vlookup(A2,'Test 2'!$A:$B,1,False)),TRUE,FALSE)"
.FormatConditions(1).Interior.Color = vbGreen
End With
End If
End Sub
And the second Formula I have also tried is:
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$A$2" Then
Dim lr As Long
lr = Range("A" & Sheet4.rows.Count).End(xlUp).Row
With Range("A2:A" & lr)
.FormatConditions.Delete
.FormatConditions.Add Type:=xlExpression, Operator:=xlExpression, Formula1:="Not(ISERROR(Vlookup(A2,'Test 2'!$A:$B,1,False)))"
.FormatConditions(1).Interior.Color = vbGreen
End With
End If
End Sub
Please Note, cross-posted with: Using VLookup with Conditional Formatting when Inserting a New Row
I will update both posts if I get an answer, thank you!