PDA

View Full Version : [SOLVED] clean a row if it doesn't start with a number except _



parscon
01-09-2014, 06:25 AM
I have this VBA code and it will clean the row that it doesn't start with a number and also i need to add _ and TD that mean also do not clean the row that start with _ or 'TD' also.

Could you please help me on this subject .

Thank you very much





Sub CleanRowifnotnumeric()
'clean a row if it doesn't start with a number

Dim rng As Range
Dim cell As Range

Set rng = ActiveSheet.Range("A1:D1").Resize(ActiveSheet.UsedRange.Count, 1)

For Each cell In rng
If IsNumeric(Left(cell.Value, 1)) = False Then cell.Rows.ClearContents
Next cell

End Sub

Kenneth Hobs
01-09-2014, 06:50 AM
Sub CleanRowifnotnumeric()
'clean a row if it doesn't start with a number
Dim rng As Range
Dim cell As Range

Set rng = Range("A1", Range("A" & ActiveSheet.UsedRange.Rows.Count))
For Each cell In rng
Debug.Print cell.Rows.Address
If IsNumeric(Left(cell.Value, 1)) = False And _
Left(cell.Value, 1) <> "_" And _
Left(cell.Value, 2) <> "TD" _
Then cell.Rows.EntireRow.ClearContents
Next cell
End Sub

parscon
01-09-2014, 06:57 AM
Thank you very much . Big Help like always .

snb
01-09-2014, 07:46 AM
Sub M_snb()
For Each cl In Columns(1).SpecialCells(2, 2)
If Left(cl, 2) = "TD" Or Left(cl, 1) = "_" Then cl.Value = 0
Next
Columns(1).SpecialCells(2, 1).EntireRow.ClearContents
End Sub