ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   delete record based on a value (https://www.excelbanter.com/excel-programming/332962-delete-record-based-value.html)

Anauna

delete record based on a value
 
Hello,

I would like to be able to delete all values greater than 60 on a
spreadsheet.
--
Thank-you and all suggestions are appreciated.

Jim Thomlinson[_4_]

delete record based on a value
 
Why not just sort and delete?
--
HTH...

Jim Thomlinson


"Anauna" wrote:

Hello,

I would like to be able to delete all values greater than 60 on a
spreadsheet.
--
Thank-you and all suggestions are appreciated.


Ron de Bruin

delete record based on a value
 
Hi

This example use AutoFilter to do this
The first cell in the range is the header cell


Sub Delete_with_Autofilter()
Dim DeleteValue As String
Dim rng As Range

DeleteValue = "60"

With ActiveSheet
.Range("A1:A100").AutoFilter Field:=1, Criteria1:=DeleteValue
With ActiveSheet.AutoFilter.Range
On Error Resume Next
Set rng = .Offset(1, 0).Resize(.Rows.Count - 1, 1) _
.SpecialCells(xlCellTypeVisible)
On Error GoTo 0
If Not rng Is Nothing Then rng.EntireRow.Delete

End With
.AutoFilterMode = False
End With
End Sub


--
Regards Ron de Bruin
http://www.rondebruin.nl


"Anauna" wrote in message ...
Hello,

I would like to be able to delete all values greater than 60 on a
spreadsheet.
--
Thank-you and all suggestions are appreciated.




William Benson

delete record based on a value
 
Assuming you mean all values in a single column, then you should put on
Autofilter and set the criterion to =60, then delete results.

If you need to look over every cell in the worksheet for values =60, that's
a different story.
Sub DelValues()
Dim c As Range

For Each c In activeSheet.UsedRange
If c.Value = 60 And IsNumeric(c.Value) Then c.Delete
Next 'c

End Sub



"Anauna" wrote in message
...
Hello,

I would like to be able to delete all values greater than 60 on a
spreadsheet.
--
Thank-you and all suggestions are appreciated.





All times are GMT +1. The time now is 10:59 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com