How to Delete Rows from a Filtered Range Without Crashing Excel


Deleting rows from a large filtered range in Microsoft Excel can take a long time, temporarily place the program into a “not responding” state, or—in a worst-case scenario—cause Excel to crash altogether. However, taking one simple step allows Excel to continue running smoothly.

Why Deleting Filtered Rows Crashes Excel

Let’s imagine you want to tidy up this dataset of 50,000 products by deleting the rows containing discontinued items.

An Excel table containing product IDs, prices per unit, and status, with the discontinued products highlighted.

To follow along as you read this guide, download a free copy of the Excel workbook used in the example. After you click the link, you’ll find the download button in the top-right corner of your screen.

One way to execute this task is to use the filter buttons that appear by default when you format the data as an Excel table. Alternatively, if your data isn’t formatted as an Excel table, select any cell in the range, and press Ctrl+Shift+L to add filter buttons manually.

Related


Everything You Need to Know About Excel Tables (And Why You Should Always Use Them)

This could totally change how you work in Excel.

First, click the filter button in the Status column, uncheck “Active,” and click “OK,” so that only the discontinued items are displayed in the table.

The filter button on a Status column in an Excel worksheet is activated, and Active is unchecked.

Next, select one cell in the range, and press Ctrl+A to select the whole range. Then, right-click the selected range, and click Delete > Entire Sheet Row. This will only delete the rows on display, meaning you can later clear the filters to display the active items again.

All the cells in a filtered Excel table are selected, and the Entire Sheet Row option in the Delete menu is highlighted.

However, at this point, Excel may warn you that the operation may take a long time to complete.

An Excel warning message that informs the user that the operation will take a significant amount of time to complete.

Related


7 Ways to Speed Up Your Excel Spreadsheets

Don’t twiddle your thumbs waiting for Excel to respond.

And it’s true—when I clicked “OK,” Excel froze for around 42 seconds—including entering the “not responding” state—before finally reactivating to display the intended result.

An Excel file that is not responding.

What’s more, when I pressed Ctrl+Z to undo the operation, Excel crashed entirely, and I had to close and restart the program.

This happens because most of the deleted rows aren’t directly next to each other. Indeed, when you look at the row headers on the left side of the data, you can see a non-continuous set of row labels, as the filtered-out data occupies all the other rows.

The row headers in a filtered Excel dataset are highlighted.

As a result, when Excel goes to delete the rows on show, it has to run through each group of contiguous cells (also known as an area) one by one. So, in this case, it will delete row 4, then rows 12 to 14, then row 16, and so on. In total, there are 11,873 areas in this data, so Excel has to perform the delete operation 11,873 times!

Sort the Data First to Prevent Excel From Crashing

To stop Excel from crashing when you delete rows from a large filtered dataset, simply sort the relevant column first.

However, before you do this, it’s worth thinking about how you want your data to be presented after you’ve deleted the relevant rows. In this example, the products are listed in the order in which they were first added to the inventory, so it’s important to retain this order in the long term.

To ensure this happens, add another column called “Index,” and type 1, 2, and 3 into the top three cells of this new column.

An index column is added to a formatted Excel table, and the numbers 1, 2, and 3 are typed into the first three cells.

As soon as you type the column header in column D, the formatted Excel table will expand one column to the right.

Then, select those three cells, and double-click the fill handle in the bottom-right corner of the selection to apply these index numbers to the remaining cells in the range.

The fill handle in the bottom-right corner of a range of selected cells is highlighted.

Related


11 Cool Double-Click Tricks in Microsoft Excel

These hidden tools could save you hours.

Next, click the filter button in the Status column, and select “Sort A To Z” or “Sort Z To A.” When you click “OK,” items with the same status are grouped together.

The Sort options in a column's filter menu in Microsoft Excel.

Now, click the filter button again, and uncheck “Active” and click “OK,” so that only the discontinued items are displayed in the table.

Cells containing the word 'Active' are deselected in the filter options of a sorted Excel column.

Notice how all the discontinued products are now in adjacent rows. This means that when you delete these rows in the next step, Excel only has to handle one area, rather than the 11,873 areas it would have had to handle if you hadn’t sorted the data first.

The row headers in a sorted and filtered Excel dataset are highlighted.

As a result, when you select all the cells in the range (Ctrl+A), right-click the selected range, and click Delete > Entire Sheet Row, Excel performs the operation in less than a second.

Now that the operation is complete, click the filter button in the Status column, clear the filters, and click “OK” to display the active items again.

The filter button on a Status column in an Excel worksheet is activated, and Active is checked.

Finally, revert the data back to its original order by sorting the table by the Index column, and delete that column if you no longer need it.

A column being deleted in Microsoft Excel.


Knowing what can cause Excel to slow down can save you from becoming frustrated with the program. For example, having too many volatile functions or unnecessarily over-formatting your worksheet makes Excel (and your computer) work harder than it needs to, so avoid these wherever possible!

By admin

Deixe um comentário

O seu endereço de email não será publicado. Campos obrigatórios marcados com *