ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How to Delte Multiple Rows Given a Value Existing (https://www.excelbanter.com/excel-programming/314512-how-delte-multiple-rows-given-value-existing.html)

Jako[_91_]

How to Delte Multiple Rows Given a Value Existing
 

Many thanks Dave that worked great !!!

Except that it only deletes the entries on one worksheet.

How would i use this code on EVERY worksheet in the active workbook?

Thanks agai

--
Jak
-----------------------------------------------------------------------
Jako's Profile: http://www.excelforum.com/member.php...nfo&userid=871
View this thread: http://www.excelforum.com/showthread.php?threadid=27169


Dave Peterson[_3_]

How to Delte Multiple Rows Given a Value Existing
 
oops. I didn't notice that last part:

Option Explicit
Sub delete_rows()
Dim lastrow As Long
Dim row_index As Long
Dim wks As Worksheet

Application.ScreenUpdating = False

For Each wks In ActiveWorkbook.Worksheets
With wks
lastrow = .Cells(.Rows.Count, "F").End(xlUp).Row
For row_index = lastrow - 1 To 1 Step -1
Select Case LCase(Cells(row_index, "F").Value)
Case Is = "yellow", "green", "red", "blue"
.Rows(row_index).Delete
End Select
Next row_index
End With
Next wks

Application.ScreenUpdating = True
End Sub

But are you still sure you want to start at lastrow-1?

Jako wrote:

Many thanks Dave that worked great !!!

Except that it only deletes the entries on one worksheet.

How would i use this code on EVERY worksheet in the active workbook?

Thanks again

--
Jako
------------------------------------------------------------------------
Jako's Profile: http://www.excelforum.com/member.php...fo&userid=8710
View this thread: http://www.excelforum.com/showthread...hreadid=271697


--

Dave Peterson



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

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