Results 1 to 13 of 13

VBA Filter Using Named Ranges as Criteria

Threaded View

Mediterranean VBA Filter Using Named Ranges... 04-25-2013, 02:33 PM
davesexcel Re: VBA Filter Using Named... 04-25-2013, 08:56 PM
Mediterranean Re: VBA Filter Using Named... 04-29-2013, 12:14 PM
AB33 Re: VBA Filter Using Named... 04-29-2013, 12:25 PM
Mediterranean Re: VBA Filter Using Named... 04-29-2013, 02:46 PM
AB33 Re: VBA Filter Using Named... 04-29-2013, 02:51 PM
Mediterranean Re: VBA Filter Using Named... 04-29-2013, 02:58 PM
AB33 Re: VBA Filter Using Named... 04-29-2013, 03:07 PM
Mediterranean Re: VBA Filter Using Named... 04-29-2013, 03:20 PM
Norie Re: VBA Filter Using Named... 04-29-2013, 03:26 PM
Mediterranean Re: VBA Filter Using Named... 04-29-2013, 03:45 PM
Norie Re: VBA Filter Using Named... 04-29-2013, 03:53 PM
Mediterranean Re: VBA Filter Using Named... 04-29-2013, 04:00 PM
  1. #1
    Registered User
    Join Date
    02-11-2013
    Location
    Dallas, TX
    MS-Off Ver
    Excel 2010
    Posts
    11

    VBA Filter Using Named Ranges as Criteria

    I am trying to filter data by named range critera. For instance, in column B, cells fall into various named ranges (B2, B10, and B12 belong to named range "FirstNamedRange"; B4, B10, and B8 belong to "SecondNamedRange"; and B22, B23, and B25 belong to "ThirdNamedRange"). As you can see from these examples, not all cells in column B are assigned to a particular named range, and cell B10 belongs to both FirstNamed Range and SecondNamedRange.

    I want to filter by a specified named ranges but cannot figure out how to indicate a named range as the criteria. Below are some codes that I have tried with no success - mismatch errors, no critera pulled, etc. To give you a general idea of my plans for this piece of code, I am going to use it to filter and show all cells belonging to FirstNamedRange and then I will use it to build a code to filter and show all cells belonging to FirstNamedRange OR SecondNamedRange, then FirstNamedRange AND SecondNamedRange....That kind of idea.

        Dim rData As Range, rCrit As Range
        Set rData = Intersect(Sheet2.UsedRange, Range("B:B"))
        Set rCrit = Sheet2.Range("FirstNamedRange")
        rData.AdvancedFilter xlFilterInPlace, rCrit
    Dim FirstNamedRange As String
    
    Sheet2.Range("A1:Z1").AutoFilter Field:=2, Criteria1:=CLng(Sheet2.Range("FirstNamedRange"))
    Thank you in advance for any help you can provide. Any forum threads I have found on the internet on this subject have proven unhelpful.
    Last edited by Mediterranean; 04-25-2013 at 02:44 PM. Reason: Added code

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1