+ Reply to Thread
Results 1 to 9 of 9

Advanced filter with blank cells / Dynamic named range with blank cells

Hybrid View

Jason_2112 Advanced filter with blank... 11-11-2010, 11:06 AM
JBeaucaire Re: Advanced filter with... 11-11-2010, 11:57 AM
Jason_2112 Re: Advanced filter with... 11-12-2010, 12:30 PM
JBeaucaire Re: Advanced filter with... 11-12-2010, 12:58 PM
Jason_2112 Re: Advanced filter with... 11-12-2010, 03:42 PM
JBeaucaire Re: Advanced filter with... 11-12-2010, 04:19 PM
Jason_2112 Re: Advanced filter with... 11-15-2010, 10:57 AM
JBeaucaire Re: Advanced filter with... 11-15-2010, 11:16 AM
Jason_2112 Re: Advanced filter with... 11-15-2010, 12:06 PM
  1. #1
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Advanced filter with blank cells / Dynamic named range with blank cells

    Record a macro of you manually sorting each of those columns after FilterCopy stuff has already run. See if you notice a diff in the resulting code.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  2. #2
    Registered User
    Join Date
    03-01-2007
    Posts
    47

    Re: Advanced filter with blank cells / Dynamic named range with blank cells

    Ok, I've figured out that the code will run by itself if the worksheet "CBList" is the active sheet, but if another sheet is active, and the macro is run from that sheet, it will not work.

    Here is the code as I have it now.

    Option Explicit
    Sub CreateDynamicRange()
    Dim LR As Long
    
    LR = Cells.Find("*", Cells(Rows.Count, Columns.Count), _
        SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
        
        Sheets("Data").Range("B6:B" & LR).AdvancedFilter Action:=xlFilterCopy, _
            CopyToRange:=Sheets("CBList").Range("A1"), Unique:=True
        Sheets("Data").Range("C6:C" & LR).AdvancedFilter Action:=xlFilterCopy, _
            CopyToRange:=Sheets("CBList").Range("C1"), Unique:=True
        Sheets("Data").Range("F6:F" & LR).AdvancedFilter Action:=xlFilterCopy, _
            CopyToRange:=Sheets("CBList").Range("E1"), Unique:=True
            
        Sheets("CBList").Range("A:A").Sort Key1:=Range("A2"), Order1:=xlAscending, Header:= _
            xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
            DataOption1:=xlSortNormal
        Sheets("CBList").Range("C:C").Sort Key1:=Range("C2"), Order1:=xlAscending, Header:= _
            xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
            DataOption1:=xlSortNormal
        Sheets("CBList").Range("E:E").Sort Key1:=Range("E2"), Order1:=xlAscending, Header:= _
            xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
            DataOption1:=xlSortNormal
                                      
    End Sub
    I ran the code for sorting as a separate macro, and it worked fine as long as the CBList sheet was active. Not sure what to do now.

    - Jason

+ 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