Moonbeam111
Board Regular
- Joined
- Sep 24, 2018
- Messages
- 98
- Office Version
- 365
- 2010
I've looked around the message board and I could not really find an answer but I hope I'm not overthinking this.
I have a vba code that looks for the value in H22 and checks to see which cell matches that value in ranges("D21:D25")and applies a background color of yellow on it.
It works fine by itself. But the ranges D21:D25 are part of a table. When I sort that table, the interior yellow color does not change with the original cell it matched. It just stays with the original cell.
So basically this:
Is what it looked like originally.
But here when i sorted Z-A. It did this:
The VBA applied color should still be on Blue but its actually stuck on Pink (Range"D21")
How do I go about fixing this?
I have a vba code that looks for the value in H22 and checks to see which cell matches that value in ranges("D21:D25")and applies a background color of yellow on it.
VBA Code:
For Each ThisCell1 In Range("H22")
For Each ThisCell3 In Range("D21:D25")
If ThisCell1.Value = ThisCell3.Value Then
ThisCell3.FormatConditions.Add(Type:=xlExpression, Formula1:=True).Interior.Color = vbYellow
End If
Exit For
Next ThisCell3
Next ThisCell1
It works fine by itself. But the ranges D21:D25 are part of a table. When I sort that table, the interior yellow color does not change with the original cell it matched. It just stays with the original cell.
So basically this:
Is what it looked like originally.
But here when i sorted Z-A. It did this:
The VBA applied color should still be on Blue but its actually stuck on Pink (Range"D21")
How do I go about fixing this?