Is there a quick way to delete large numbers of rows?

JenniferMurphy

Well-known Member
Joined
Jul 23, 2011
Messages
2,525
Office Version
  1. 365
Platform
  1. Windows
I downloaded a csv file from the CDC showing life expectancy for different races and genders from 1900 to 2018. I only want data for certain demographics for certain years (1900, 1950, 2018).

Is there a way I can delete all rows that do not have one of those years in Column A?

Here's a minisheet for the first few rows:

NCHS_-_Death_rates_and_life_expectancy_at_birth (original).csv
ABCDE
1YearRaceSexAverage Life Expectancy (Years)Age-adjusted Death Rate
21900All RacesBoth Sexes47.32,518.00
31901All RacesBoth Sexes49.12,473.10
41902All RacesBoth Sexes51.52,301.30
51903All RacesBoth Sexes50.52,379.00
61904All RacesBoth Sexes47.62,502.50
71905All RacesBoth Sexes48.72,423.70
81906All RacesBoth Sexes48.72,399.00
91907All RacesBoth Sexes47.62,494.40
101908All RacesBoth Sexes51.12,298.90
111909All RacesBoth Sexes52.12,249.20
NCHS_-_Death_rates_and_life_exp


Thanks
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
I found a way that seems to work.
  1. Select the entire dataset. For me that was columns A-E and rows 2-end.
  2. Click the Data tab.
  3. In the Sort & Filter section, click on Filter.
  4. When the little "filter" icons (they look like sort icons) appear, click on the one over the Year column.
  5. Make sure that the Select All box is checked.
  6. Uncheck the boxes next to the years I want to keep (1900, 1950, 2018).
  7. Right-click in the data area (Not in the row numbers) and select Delete.
  8. Click on Filter again to get rid of the little filter icons.
Done! Magic!
 
Upvote 0
I'm marking my own reply as the answer, but if someone posts a better one, I'll change that. 🤔😏😉
 
Upvote 0
Jennifer
A power query solution. Simply bring your data into the PQ editor and filter as shown below.
Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Filtered Rows" = Table.SelectRows(Source, each [Year] = 1900 or [Year] = 1950 or [Year] = 2018)
in
    #"Filtered Rows"

or using your solution, click on the Number filters and then select your years to keep. No need to check any boxes.
 
Upvote 0
Solution

Forum statistics

Threads
1,214,641
Messages
6,120,694
Members
448,979
Latest member
DET4492

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top