removing specific rows in a worksheet

  • Thread starter Thread starter Louise
  • Start date Start date
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
 
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
 
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.
 
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
 
Hello
This does remove the text, however the row itself remains, I need to remove
the actual row too. Any ideas?

Thanks.
Louise
 
I've tried this again and it seems to have worked. Thanks for your help.
Louise
 
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
 
Hi Louise,
Check the blanks between Store and Manager, my code is working for me
 
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top