Auto Filter

nianchi111

Board Regular
Joined
Aug 24, 2007
Messages
197
Office Version
  1. 365
Hi All,

I have a data in a sheet

Need to filter column K..

If #N/A then move the filtered data to next sheet.
Leave other data in sheet 1.

Important thing is that if "#N/A" not found then do nothing.

Thanks,
Vimal Vikraman.
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
.. move the filtered data to next sheet.
Does the "next sheet" already exist?
If so ..
- What is its name?
- Does it (or might it) already have data on it? If so, what happens to that existing data? (eg It should get deleted or the new data should get added below etc)
 
Upvote 0
Does the "next sheet" already exist? = Yes
- What is its name? = Sheet 2
- Does it (or might it) already have data on it? = No data only the header
 
Upvote 0
Does the "next sheet" already exist? = Yes
- What is its name? = Sheet 2
- Does it (or might it) already have data on it? = No data only the header
Try this with a copy of your workbook.

Code:
Sub Move_NA()
  Dim rCrit As Range
  
  With Sheets("Sheet 1")
    Set rCrit = .Range("AA1:AA2")
    rCrit.Cells(2).Formula = "=ISNA(K2)"
    With .Range("A1").CurrentRegion
      .AdvancedFilter Action:=xlFilterInPlace, CriteriaRange:=rCrit, Unique:=False
      .Offset(1).Copy Destination:=Sheets("Sheet 2").Range("A2")
      On Error Resume Next
      .Offset(1).Resize(.Rows.Count - 1).SpecialCells(xlVisible).EntireRow.Delete
      rCrit.ClearContents
      On Error GoTo 0
    End With
    If .FilterMode Then .ShowAllData
  End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,240
Members
452,621
Latest member
Laura_PinksBTHFT

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