VBA Filter by range

vicx2ww

New Member
Joined
Mar 30, 2017
Messages
11
Hi All

I am trying to filter by a range of values , but nothing happens. please help.

PS: howto Debug.Print a range (like workbook ..sheet ... A1:A100)

Debug.Print rngallean.Value
Debug.Print rng1.Value

Code:
    Dim template As String
    
    template = ThisWorkbook.Name
    
    
    Dim ltrw As Long
    ltrw = Range("F" & Rows.Count).End(xlUp).Row

        Dim rng1 As Range
        Set rng1 = Range("F6:F" & ltrw)
        
        Dim Ean As String
        
        Workbooks.Open (Range("A1").Value & "EanCode.xlsx")
        Ean = ActiveWorkbook.Name
        
        Dim lastRow As Long
        lastRow = Range("a" & Rows.Count).End(xlUp).Row
        Dim rngallean As Range
        Set rngallean = Range("A1:I" & lastRow)
        
       
        
[U][B]        rngallean.AdvancedFilter Action:=xlFilterInPlace, CriteriaRange:=rng1, Unique:=False[/B][/U]
   
' version 2         
[U][B]    Workbooks(Ean).Sheets("EanCode").Range("A1:I20000").AdvanceFilter Action:=xlFilterInPlace, CriteriaRange:= _
    Workbooks(template).Sheets("Template").Range("F6:F1000"), Unique:=False[/B][/U]
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
I think you may have more success if you post an example of your data, and your expected results.
 
Upvote 0
I have an Excel file were i run a macro. A part of IT consist în opening another file were i have raw data. This raw data i want to filter by The results that i get în The first excel file. I wanted to use ranges. I tried 2 versions. I get no error neither a result.
 
Upvote 0
I am interested in seeing what your data looks like, and what the range you are trying to filter by looks like.
There are different things to consider based on the data you are working with. Being able to see that would go a long way.
I don't like making up data on my own, only to discover that it won't work for you because your data/situation is vastly different.
 
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