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.
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 theicon 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!)
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.
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.![]()
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
- Jason
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks