Hi All, i want a VBA code to delete all rows that donot contain the "/" character. So column D contains part numbers in my sheet. We have two formats for part numbers one contains only numbers and the other will always have a / in it.
I have tried the following code but this deletes all rows, however if i change the value to a specific value that i can see is in my spreadsheet it does delete all rows other than the row with the specific value.
I was trying to use "*/*" hoping this would search on anything in the cell that contains /.
the codes is shown below, any help would be appreciated.
' Defines variables
Dim Cell As Range, cRange As Range, LastRow As Long, x As Long
' Defines LastRow as the last row of data based on column E
LastRow = ActiveSheet.Cells(Rows.Count, "D").End(xlUp).Row
' Sets check range as D1 to the last row of D
Set cRange = Range("D1:D" & LastRow)
' For each cell in the check range, working from the bottom upwards
For x = cRange.Cells.Count To 1 Step -1
With cRange.Cells(x)
' If the cell does not contain one of the listed values then...
If .Value <> "*/*" Then
' Delete that row
.EntireRow.Delete
End If
End With
' Check next cell, working upwards
Next x
Bookmarks