ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Ron de Bruins Delete Row Code Q (https://www.excelbanter.com/excel-programming/300825-ron-de-bruins-delete-row-code-q.html)

John

Ron de Bruins Delete Row Code Q
 
Just used one of Ron de Bruins pieces of code to delete rows if a certain
value is in Column C, I tailored it somewhat to what I want (quite chuffed
with myself!), however I would prefer if the values that I want deleted in
Column B looked at a named range (i..e I could expand with entries I want
deleted without any change required to the VB bit). I'm also looking for the
code to also delete all rows that have a value of " " i.e. blank in Column C
of Sheet Sales Mix

Thanks for the code Ron

Public Sub SelectiveDelete()
Application.ScreenUpdating = False

With Application
.Calculation = xlManual
.MaxChange = 0.001
End With

Dim Lrow As Long
Dim CalcMode As Long
Dim StartRow As Long
Dim EndRow As Long


Sheets("Sales Mix").Select
With ActiveSheet
.DisplayPageBreaks = False

StartRow = 2
EndRow = .Cells(.Rows.Count, "C").End(xlUp).Row
For Lrow = EndRow To StartRow Step -1
If IsError(.Cells(Lrow, "C").Value) Then
'Do nothing, This avoid a error if there is a error in the
cell

ElseIf .Cells(Lrow, "c").Value = "37" Then
..Rows(Lrow).EntireRow.Delete shift:=xlUp
'This will delete each row with the Value "ron" in Column A,
case sensitive.

End If
Next
End With


With Application
.Calculation = xlAutomatic
.MaxChange = 0.001
End With
ActiveWorkbook.PrecisionAsDisplayed = False
Application.ScreenUpdating = True

End Sub




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

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