Deleteing some Rows
I am looking for some help to delete the rows in a sheet which have some
Specific words in the cell. For example: i have sub total for every 10 to 15 lines and would like to find out the cell which have "sub total" word int it and delete the whole row. Thanks in advance |
One way:
Sub DeleteRow() 'Adapted from Microsoft code found at 'msdn.microsoft.com Dim sFind As String Dim Rng As Range Dim sFindRow As Long sFind = "*sub*total*" Set Rng = Range("A:A").Find(What:=sFind, lookat:=xlWhole) While Not Rng Is Nothing sFindRow = Rng.Row Rng.EntireRow.Delete Set Rng = Range("A" & sFindRow - 1 & ":A" & _ Rows.Count) _ .Find(What:=sFind, lookat:=xlWhole) Wend End Sub To run, press ALT+F11, go to Insert Module, and paste in the code above. Press ALT+Q. And go to Tools Macro Macros to run. This assumes you have data in col. A. HTH Jason Atlanta, GA, USA -----Original Message----- I am looking for some help to delete the rows in a sheet which have some Specific words in the cell. For example: i have sub total for every 10 to 15 lines and would like to find out the cell which have "sub total" word int it and delete the whole row. Thanks in advance . |
All times are GMT +1. The time now is 02:27 PM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com