![]() |
Deleting a row based on the value in column A
I am trying to delete rows in my spreadsheet based upon
the value that appears in column A. I would like to delete the row only if it is NON numeric. Can this be done ? Thanks in advance. Steve |
Deleting a row based on the value in column A
Hi Steve
Try this Sub Example1() Dim Firstrow As Long Dim Lastrow As Long Dim Lrow As Long Dim CalcMode As Long With Application CalcMode = .Calculation .Calculation = xlCalculationManual .ScreenUpdating = False End With Firstrow = ActiveSheet.UsedRange.Cells(1).Row Lastrow = ActiveSheet.UsedRange.Rows.Count + Firstrow - 1 With ActiveSheet .DisplayPageBreaks = False For Lrow = Lastrow To Firstrow Step -1 If IsError(.Cells(Lrow, "A").Value) Then 'Do nothing, This avoid a error if there is a error in the cell ElseIf Not IsNumeric(.Cells(Lrow, "A").Value) Then .Rows(Lrow).Delete End If Next End With With Application .ScreenUpdating = True .Calculation = CalcMode End With End Sub More info on this page http://www.rondebruin.nl/delete.htm -- Regards Ron de Bruin http://www.rondebruin.nl "Steve" wrote in message ... I am trying to delete rows in my spreadsheet based upon the value that appears in column A. I would like to delete the row only if it is NON numeric. Can this be done ? Thanks in advance. Steve |
Deleting a row based on the value in column A
and again.
Steve -----Original Message----- Hi Steve Try this Sub Example1() Dim Firstrow As Long Dim Lastrow As Long Dim Lrow As Long Dim CalcMode As Long With Application CalcMode = .Calculation .Calculation = xlCalculationManual .ScreenUpdating = False End With Firstrow = ActiveSheet.UsedRange.Cells(1).Row Lastrow = ActiveSheet.UsedRange.Rows.Count + Firstrow - 1 With ActiveSheet .DisplayPageBreaks = False For Lrow = Lastrow To Firstrow Step -1 If IsError(.Cells(Lrow, "A").Value) Then 'Do nothing, This avoid a error if there is a error in the cell ElseIf Not IsNumeric(.Cells(Lrow, "A").Value) Then .Rows(Lrow).Delete End If Next End With With Application .ScreenUpdating = True .Calculation = CalcMode End With End Sub More info on this page http://www.rondebruin.nl/delete.htm -- Regards Ron de Bruin http://www.rondebruin.nl "Steve" wrote in message ... I am trying to delete rows in my spreadsheet based upon the value that appears in column A. I would like to delete the row only if it is NON numeric. Can this be done ? Thanks in advance. Steve . |
All times are GMT +1. The time now is 07:27 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com