advanced filter doesn't work for me

Hasson

Active Member
Joined
Apr 8, 2021
Messages
390
Office Version
  1. 2016
Platform
  1. Windows
hello
I have sheet2 contains values in column B and sheet1 contains data from A:F . I want using advanced filter . so the result in sheet2 based on column B should match with column A in sheet1 and brings filterd data in row8 .
VBA Code:
Sub AdvFilter()
  Dim rCrit As Range
  
 Dim ws As Worksheet
    Set ws = Sheets("sheet2")
  Set rCrit = ws.Range("B1:B2")
 With ThisWorkbook.Worksheets("sheet1")
  Range("A1", Range("E" & Rows.Count).End(xlUp)).Resize(, 5).AdvancedFilter 1, rCrit, Sheets("sheet2").Cells(8)
End With

End Sub
any chance to fixing this code
 
@HaHoBe actually I can figure out your idea and prefer to put inside the code like this .
Rich (BB code):
Set ws = .Worksheets("sheet2")
  ws.Range("A8").CurrentRegion.ClearContents
it works perfectly !(y)
many thanks buddy ;)
 
Upvote 0

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.

Forum statistics

Threads
1,215,002
Messages
6,122,652
Members
449,092
Latest member
peppernaut

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