Hi,
how can I achieve deleting the entire row based on a text starting with letter "X"
actually, I already have the code below from my previous inquiry and I just forgot to include this particular requirement. is there any way to embed the missing function?
Here's what my worksheet looks like:
And here's how I expect it to be after executing the macro.
Thanks a lot for the help!
how can I achieve deleting the entire row based on a text starting with letter "X"
actually, I already have the code below from my previous inquiry and I just forgot to include this particular requirement. is there any way to embed the missing function?
Code:
sub duplicate()
Dim Rng As Range, Dn As Range, n As Long
Dim Lst As Long, nRng As Range
Lst = Range("B" & Rows.Count).End(xlUp).Row
With CreateObject("scripting.dictionary")
.CompareMode = vbTextCompare
For n = Lst To 1 Step -1
If Not .Exists(Range("B" & n).Value) Then
.Add Range("B" & n).Value, Nothing
Else
If nRng Is Nothing Then
Set nRng = Range("B" & n)
Else
Set nRng = Union(nRng, Range("B" & n))
End If
End If
Next n
If Not nRng Is Nothing Then nRng.EntireRow.Delete
End With
End Sub
Here's what my worksheet looks like:
PHP:
Row Column A Column B Column C Column D
1 PHMBIA Maricel A. Chemical ---
2 PHMBIA Maricel A. Chemical ---
3 PHMBIA Maricel A. Chemical 9/17/2015
4 PHMABC Mari L. Refinery ---
5 PHMABC Mari L. Refinery ---
6 PHMABC Mari L. Refinery ---
7 PHMABC Mari L. Refinery ---
8 XHAMAO Mall A. Sup ---
9 XHAMAO Mall A. Sup ---
10 XHAMAO Mall A. Sup 9/17/2015
And here's how I expect it to be after executing the macro.
PHP:
Row Column A Column B Column C Column D
3 PHMBIA Maricel A. Chemical 9/17/2015
7 PHMABC Mari L. Refinery ---
Thanks a lot for the help!