• Blog
  • Excel Downloads
    • Audit Tickmark Toolbar
  • Courses
  • Contact
  • Checkout

Excel Zoom

...because it's more than just a calculator


Remove All Rows Containing Certain Data

July 20, 2015 by Mark 7 Comments

Recently I had some data from a website that was poorly formatted, but I needed to get it into a spreadsheet to work with. When I copied the data into the spreadsheet, I needed to remove all of the rows that contained certain irrelevant data, such as repeated header fields.

Other use cases might require you to delete any rows containing someone’s name, a location, or some other information to trim the excess data from your sheet.

How to Remove all Rows Containing Certain Data

  1. Select all of your data, including the data you wish to remove.
  2. find-replacePress Ctrl F to open the Find and Replace window.
  3. Type the text that is contained in the row you wish to delete. For example if you need to delete rows with someone’s name, type that name in.
  4. Click the Find All button.
    • This will show a list of all cells containing the data you searched for below the search box.
  5. delete-rowClick on one of the results that appear below the search box, then press Ctrl A.
    • All results should be highlighted now. Also, if you notice on your spreadsheet, each cell containing what you searched for will be selected.
  6. Click the Close button on the Find and Replace window.
  7. Press Ctrl – to open the Delete window.
  8. Select the Entire Row option, and press the OK button.

All rows containing the data you wanted to remove should be gone now!

You can also remove an entire column of data that contains certain information in a similar manner. To remove the entire column, simply select the Entire Column option in the last step above.

As with any data modification, be sure to have a copy of your data saved elsewhere as a backup just in case you accidentally remove some important information. This will ensure that when trying to remove all rows containing certain data, you do so in the safest possible way.

Remove Certain Rows Containing Certain Data with VBA

In the developer tab, go to Visual Basic as normal and create a module like the one below. Change and amend the code to your needs and then simply run the module on your sheet.

 

 Sub Delete_All_Rows_IF_Cell_Contains_Certain_String_Text()
    Dim lRow As Long
    Dim iCntr As Long
    lRow = 1000
    For iCntr = lRow To 1 Step -1
        If Cells(iCntr, 3).Value = "Certain data to delete here" Then
            Rows(iCntr).Delete
        End If
    Next
    End 

Number “3” in the ‘If Cells (iCntr, 3).Value represents the third column (C)
lRow = 1000 means it will check the first 1000 rows.

Filed Under: Tips Tagged With: Cell, Row, Shortcuts, Tips

Looking For More Help?

Contact us with any specific questions or feedback. We love to hear from you!

Want to level up your career? See our amazing Certificated Excel Courses and be the office Hero with your new found knowledge!

Looking for the Excel Audit Tickmark Toolbar? click here, NOW ONLY $25!

Subscribe to our mailing list
  • Facebook
  • Twitter

Search this site…

Categories

  • Macros (34)
  • Tips (67)
  • Uncategorized (23)



Copyright © 2023 · Magazine Pro Theme on Genesis Framework · WordPress · Log in

Login Form

Lost your password?