Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Macro for fast deletion of rows that conatin certain data.
I need a macro that deletes all rows in a worksheet in which a certain text
string is found in a cell in that row? e.g. If a cell in column "B" contains a text string "6:00 AM", then delete the entire row. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Macro for fast deletion of rows that conatin certain data.
Try the below
Sub DeleteRows() Dim lngRow As Long For lngRow = Cells(Rows.Count, 2).End(xlUp).Row To 1 Step -1 If Range("B" & lngRow).Text = "6:00 AM" Then Rows(lngRow).Delete Next End Sub If this post helps click Yes --------------- Jacob Skaria "PhilBennett" wrote: I need a macro that deletes all rows in a worksheet in which a certain text string is found in a cell in that row? e.g. If a cell in column "B" contains a text string "6:00 AM", then delete the entire row. |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Macro for fast deletion of rows that conatin certain data.
Hi Phil
I would loop through the file starting at the last row and build a collection of the rows with the text 6:00 AM in them, then delete that collection at the finish of the routine. Sub DeleteRows6AM() Dim lr As Long, i As Long Dim delrng As Range, ws As Worksheet Set ws = ActiveSheet lr = ws.Cells(Rows.Count, 2).End(xlUp).Row For i = lr To 1 Step -1 If Cells(i, 2).Text = "6:00 AM" Then If delrng Is Nothing Then Set delrng = ws.Rows(i) Else Set delrng = Application.Union(delrng, ws.Rows(i)) End If End If Next delrng.Delete End Sub -- Regards Roger Govier "PhilBennett" wrote in message ... I need a macro that deletes all rows in a worksheet in which a certain text string is found in a cell in that row? e.g. If a cell in column "B" contains a text string "6:00 AM", then delete the entire row. __________ Information from ESET Smart Security, version of virus signature database 4527 (20091020) __________ The message was checked by ESET Smart Security. http://www.eset.com __________ Information from ESET Smart Security, version of virus signature database 4527 (20091020) __________ The message was checked by ESET Smart Security. http://www.eset.com |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Fast Way to Delete Rows from Big Spreadsheet (Using VBA) | Excel Programming | |||
Automatic Deletion of Rows | New Users to Excel | |||
On deletion of rows | Excel Discussion (Misc queries) | |||
Need a fast way to delete rows | Excel Discussion (Misc queries) | |||
Deletion of rows where a value is satisfied | Excel Programming |