Macro to Filter and Delete Rows

cr2289

New Member
Joined
Jul 21, 2016
Messages
26
Office Version
  1. 365
Platform
  1. Windows
I see posts for this but can't seem to get any of the solutions to work.

I have spreadsheets that will contain numerical and text values in column F. The number of rows on the spreadsheets will vary.

There is a header row. I need to filter an array in column F (i.e., 1, 2, C14) to the end of the spreadsheet containing data - then delete those rows without leaving any empty rows on the spreadsheet. Help?
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
What data exactly in column "F" needs to be deleted ?
IS the data the only data in each cell, or is it partial data ?
 
Last edited:
Upvote 0
Hi, Michael.

The values in column F are both text and numbers. Examples are: 0 , 1 , 5, C14, D5. I need to filter out specific codes, just 1 & D5, and delete the rows with those values in column F. The number of rows on the spreadsheets will vary, so I need a macro that will select to the bottom row of any spreadsheet.

Thank you!
 
Upvote 0
Michael, a couple more things. The spreadsheet has a header row and columns A thru AC. Thank you!!!
 
Upvote 0
How about
Code:
Sub cr2289()
   Dim Ary As Variant
   
   Ary = Array("1", "D5")
   With ActiveSheet
      .Range("A1:F1").AutoFilter 6, Ary, xlFilterValues
      .AutoFilter.Range.Offset(1).EntireRow.Delete
      .AutoFilterMode = False
   End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,175
Members
453,021
Latest member
Justyna P

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