PDA

View Full Version : [SOLVED] if find none numeric data on cloumn A just clean the column A



parscon
02-13-2014, 02:04 AM
I have a VBA code that check column A and if does not find and numeric data it will delete the row , now i need clean only the cell on column A
Thank you



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 Cells.Rows.Address
If IsNumeric(Left(cell.Value, 1)) = False And _
Left(cell.Value, 1) <> "CH" And _
Left(cell.Value, 1) <> "ZM" And _
Left(cell.Value, 1) <> "ZM" _
Then cell.Rows.Cells.Value.ClearContents

Next cell
End Sub

Tom Jones
02-13-2014, 02:19 AM
Try this:



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 Cells.Rows.Address
If IsNumeric(Left(cell.Value, 1)) = False And _
Left(cell.Value, 1) <> "CH" And _
Left(cell.Value, 1) <> "ZM" And _
Left(cell.Value, 1) <> "ZM" _
Then cell.ClearContents

Next cell
End Sub

parscon
02-13-2014, 02:23 AM
Thank you very much for your big help , it is work very well.