tonye104292
New Member
- Joined
- Jul 5, 2013
- Messages
- 4
Hi all, long time reader, first time poster.
I have the code below (not mine but it runs/works fine) that basically deletes a row in a sheet if a cell in that row equals a specific value (in this case, if it equals Total World, Europe, North, or South).
Im wondering if there is a way to modify the code below so if cell.Value equals a cell in a range in a worksheet, then it deletes that row. This would be instead of me specifying in the code "cell.Value = abc OR cell.Value = def" in order to save time and not specify in the code the hundreds of values that I want to add.
Essentially, I want to post the values in the quotes below "Total World, Europe, North, South" in a range in a worksheet, rather than in the code. Highlighted in red is what I want to modify.
I have the code below (not mine but it runs/works fine) that basically deletes a row in a sheet if a cell in that row equals a specific value (in this case, if it equals Total World, Europe, North, or South).
Im wondering if there is a way to modify the code below so if cell.Value equals a cell in a range in a worksheet, then it deletes that row. This would be instead of me specifying in the code "cell.Value = abc OR cell.Value = def" in order to save time and not specify in the code the hundreds of values that I want to add.
Essentially, I want to post the values in the quotes below "Total World, Europe, North, South" in a range in a worksheet, rather than in the code. Highlighted in red is what I want to modify.
Code:
Sub DeleteTotalClusterRows()
Dim rng As Range, cell As Range, del As Range
Set rng = Intersect(Range("H:H"), ActiveSheet.UsedRange)
For Each cell In rng
[COLOR=#ff0000]If (cell.Value) = "Total World" Or (cell.Value) = "Europe," Or (cell.Value) = "North" Or (cell.Value) = "South" _[/COLOR]
Then
If del Is Nothing Then
Set del = cell
Else: Set del = Union(del, cell)
End If
End If
Next cell
On Error Resume Next
del.EntireRow.Delete
End Sub