I have some simple VBA that highlights the entire row if fields in a column match a certain criteria, however, I would now like the VBA to look at the cells in another column that have been highlighted and delete the row if the cell contains the same value above or below. See example below, rows in orange have been highlighted based on VBA where values in column 'B' are equal to "User Provided". I now need those cells in column A that have been highlighted in orange and all other cells in column A that have the same value as the cell in column A that has been highlighted to be deleted.
[TABLE="width: 200"]
<TBODY>[TR]
[TD]A
[/TD]
[TD]B
[/TD]
[/TR]
[TR]
[TD]114
[/TD]
[TD]User Provided
[/TD]
[/TR]
[TR]
[TD]114
[/TD]
[TD]Non Dom
[/TD]
[/TR]
[TR]
[TD]115
[/TD]
[TD]User Provided
[/TD]
[/TR]
[TR]
[TD]115
[/TD]
[TD]Non Dom
[/TD]
[/TR]
[TR]
[TD]116
[/TD]
[TD]No Alloc
[/TD]
[/TR]
[TR]
[TD]116
[/TD]
[TD]Non Dom
[/TD]
[/TR]
</TBODY>[/TABLE]
If the VBA was run on the above you would just be left with the below, all other rows will be deleted
[TABLE="width: 200"]
<TBODY>[TR]
[TD]A
[/TD]
[TD]B
[/TD]
[/TR]
[TR]
[TD]116
[/TD]
[TD]No Alloc
[/TD]
[/TR]
[TR]
[TD]116
[/TD]
[TD]Non Dom
[/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
</TBODY>[/TABLE]
This is the script I've used to highlight the rows:
Sub orange()
Dim LR As Long, i As Long
LR = Range("L" & Rows.Count).End(xlUp).Row
For i = 1 To LR
With Range("L" & i)
If .Value = "User Provided" Then .EntireRow.Interior.ColorIndex = 45
End With
Next i
End Sub
Thanks!
[TABLE="width: 200"]
<TBODY>[TR]
[TD]A
[/TD]
[TD]B
[/TD]
[/TR]
[TR]
[TD]114
[/TD]
[TD]User Provided
[/TD]
[/TR]
[TR]
[TD]114
[/TD]
[TD]Non Dom
[/TD]
[/TR]
[TR]
[TD]115
[/TD]
[TD]User Provided
[/TD]
[/TR]
[TR]
[TD]115
[/TD]
[TD]Non Dom
[/TD]
[/TR]
[TR]
[TD]116
[/TD]
[TD]No Alloc
[/TD]
[/TR]
[TR]
[TD]116
[/TD]
[TD]Non Dom
[/TD]
[/TR]
</TBODY>[/TABLE]
If the VBA was run on the above you would just be left with the below, all other rows will be deleted
[TABLE="width: 200"]
<TBODY>[TR]
[TD]A
[/TD]
[TD]B
[/TD]
[/TR]
[TR]
[TD]116
[/TD]
[TD]No Alloc
[/TD]
[/TR]
[TR]
[TD]116
[/TD]
[TD]Non Dom
[/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
</TBODY>[/TABLE]
This is the script I've used to highlight the rows:
Sub orange()
Dim LR As Long, i As Long
LR = Range("L" & Rows.Count).End(xlUp).Row
For i = 1 To LR
With Range("L" & i)
If .Value = "User Provided" Then .EntireRow.Interior.ColorIndex = 45
End With
Next i
End Sub
Thanks!