+ Reply to Thread
Results 1 to 3 of 3

Relative Autofilter using Named Ranges

  1. #1
    Registered User
    Join Date
    12-02-2004
    Posts
    2

    Relative Autofilter using Named Ranges

    This is the challenge I'm facing:

    I want to create macro's which are intended to pre-autofilter data in a sheet. However, if new columns get insterted or re-arranged (it's a living file), all macro's need to be changed again since the columns get shifted and so does the FIELD:= value of the Autofilter command. I want to keep the macro's flexible by making the Autofilter use relative Range names instead of 1 for column A, etc...

    Current Example (filter col B on YES)

    Selection.AutoFilter Field:=2, Criteria1:="YES"

    Desired Example (filter name defined Range on YES)

    Selection.AutoFilter Field:=RANGENAME, Criteria1:="YES"

    With the RANGENAME I want to define a range like cell B2 until B10 [=Sheet1!$B$2:$B$10]

    I think I have to define a variable with DIM, but am getting stuck in my trail and error process... any help is really aprreciated!

    Thanks,
    BA

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Try

    Please Login or Register  to view this content.
    Are you sure you need VBA, why not a PivotTable?
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Registered User
    Join Date
    12-02-2004
    Posts
    2
    RoyUk,

    Thanks for the suggestion (it gave errors) but anyway this will still not fix the basic issue, since the Range is still statically defined to b2:b65536... whereas I don't want to have the Column and Cell references in the macro.

    I just want to use the Range name (Insert > Name > Define) and refer to the name of that range, in the macro.

    Please Login or Register  to view this content.
    Any further ideas??
    Last edited by VBA Noob; 11-01-2007 at 05:27 AM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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