View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Rick Rothstein Rick Rothstein is offline
external usenet poster
 
Posts: 5,934
Default delete row if text not in specific format

Assuming you did **not** mean the cells were Custom Formatted with the
number format you showed; but rather there were multiple type entries in
Column B and that you only wanted to preserve rows whose Column B cells
contained entries that looked like you pattern, then try this macro...

Sub RemoveNumbers()
Dim X As Long, LastRow As Long
Const StartRow As Long = 2
Const DataColumn As String = "B"
Const Pattern As String = "##.######.#######.##.###.####.####"
With Worksheets("Sheet2")
LastRow = .Cells(.Rows.Count, DataColumn).End(xlUp).Row
For X = LastRow To StartRow Step -1
If Not .Cells(X, DataColumn).Value Like Pattern Then
.Cells(X, DataColumn).EntireRow.Delete
End If
Next
End With
End Sub

As with all macros, you should test this out on a copy of your data since
you **cannot** Undo worksheet changes produced by VB code.

--
Rick (MVP - Excel)


"Abdul" wrote in message
...
Hi,

I have data in my column B

i want to delete all rows which are not in the specific format
00.000000.0000000.00.000.0000.0000

(zeros with any number)

thanks