sorting

new2vba

Board Regular
Joined
Aug 15, 2006
Messages
146
I have added a sort to an advancedfiltercopy, but it doesn't do the sort. any ideas?

Code:
Range("A1:i48").AdvancedFilter Action:=xlFilterCopy, CriteriaRange:=Range( _
        "j1:j2"), CopyToRange:=Range("a201:b201"), Unique:=False
 

Range("a201:b201").Sort _
      Key1:=Range("b201"), _
      Order1:=xlAscending, _
      Header:=xlYes, _
      OrderCustom:=1, _
      MatchCase:=False, _
      Orientation:=xlTopToBottom
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand

Barry Katcher

Well-known Member
Joined
Feb 25, 2002
Messages
4,053
Just giving it a cursory glance, it appears your sort range is only one row.

Range("a201:b201").Sort

Try:
Code:
    Range("A201:B300").Select
    Selection.Sort Key1:=Range("B202"), Order1:=xlAscending, Header:=xlGuess _
        , OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
[/quote]
 

new2vba

Board Regular
Joined
Aug 15, 2006
Messages
146
new issue

Just giving it a cursory glance, it appears your sort range is only one row.

Range("a201:b201").Sort

Try:
Code:
    Range("A201:B300").Select
    Selection.Sort Key1:=Range("B202"), Order1:=xlAscending, Header:=xlGuess _
        , OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
[/quote]After trying your solution, I realized some of the formatting I had applied to certain cells didn't move with the cell. To be more specific: I have the interior and border of some cells colored...after the sort, all of the interior colors are where they need to be, but some of the borders are not. any ideas?
 

Barry Katcher

Well-known Member
Joined
Feb 25, 2002
Messages
4,053
Hmm, I just tested it and yup, you're right; the patterns are o.k. but the borders aren't. Don't know - maybe someone else on the Board can help.
 

new2vba

Board Regular
Joined
Aug 15, 2006
Messages
146
Hmm, I just tested it and yup, you're right; the patterns are o.k. but the borders aren't. Don't know - maybe someone else on the Board can help.
Thanks Barry
 

Forum statistics

Threads
1,144,392
Messages
5,724,078
Members
422,536
Latest member
Zeeshan53

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
Top