removing specific rows in a worksheet

L

Louise

Hi all

I have a large worksheet containing thousands of rows beginning with the
words 'store manager'. I need to remove every row in the workbook beginning
with these two words.

Is there an easy way to do this?

Thank you.
Louise
 
E

Eduardo

Hi Louise,
Try this backup your file first
I suppose that Store Manager is in column C, change it to fit your
requirements

Sub delete_Me()
Dim copyrange As Range
Lastrow = Cells(Cells.Rows.Count, "C").End(xlUp).Row
Set MyRange = Range("C1:C" & Lastrow)
For Each c In MyRange
If InStr(c, "Store Manager") Then
If copyrange Is Nothing Then
Set copyrange = c.EntireRow
Else
Set copyrange = Union(copyrange, c.EntireRow)
End If
End If
Next
If Not copyrange Is Nothing Then
copyrange.Delete
End If
End Sub
 
P

Pecoflyer

Louise;193598 said:
Hi all

I have a large worksheet containing thousands of rows beginning wit
the
words 'store manager'. I need to remove every row in the workboo
beginning
with these two words.

Is there an easy way to do this?

Thank you.
Louise

Hi,
have a look at 'this site' (http://www.rondebruin.nl/delete.htm) unde
the title "Code example" and adapt to your needs.
If you don't succeed, joining as member ( free) allows to ulpoad
sample file.
I can then do it for you

--
Pecoflye

Cheers -
*'Membership is free' (http://www.thecodecage.com)* & allows fil
upload ->faster and better answers

*Adding your XL version* to your post helps finding solution faste
 
S

Sheeloo

Filter on 'Starts with' Store Manager
Delete the filtered rows
(You may have to press F5 and Choose Special and then click on Visible Cells
only)

Do make a copy before experimenting or make sure that you do not save till
you are satisfied with the results.
 
L

Louise

Hi Eduardo

Thank you for your prompt reply. I can't seem to get this to work. I have
changed the column letter to A and have run the macro but nothing happens? I
have shown below how i have edited the macro - have I done something wrong or
is there something on here still referencing column C, as in your example,
that I've missed?

Sub test()
Dim copyrange As Range
Lastrow = Cells(Cells.Rows.Count, "A").End(xlUp).Row
Set MyRange = Range("A1:A" & Lastrow)
For Each c In MyRange
If InStr(c, "Store Manager") Then
If copyrange Is Nothing Then
Set copyrange = c.EntireRow
Else
Set copyrange = Union(copyrange, c.EntireRow)
End If
End If
Next
If Not copyrange Is Nothing Then
copyrange.Delete
End If
End Sub

Thanks again.
Louise
 
L

Louise

Hello
This does remove the text, however the row itself remains, I need to remove
the actual row too. Any ideas?

Thanks.
Louise
 
E

Eduardo

Hi Louise,
I run it and is working, please check that the name you have in the macro is
the same in the spreadsheet, look at the blanks
 
D

dleo

Select the entire column and sort. Find where all of the "store manager"s
are. Select your rows, right click (or Ctrl+click if on a mac), select Delete.
 
Top