Macro Button to Sort Columns - Troubleshooting ideas?

M

Munchkin

My worksheets has 500 rows / 8 columns & there is a Header Row. Column A =
acct. number, Column B = Cutomer Name, Column C = Department, Column D =
Manager. I created marcos that sort specific columns with the click of a
button. When you sort by C or D, it works fine, but if you then try to
resort by account number Row 4 is excluded from the sort - even though my
macro includes it (see below) Any idea why?

Range("A4").Select
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlToRight)).Select
Selection.Sort Key1:=Range("A4"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Range("A4").Select
 
D

Don Guillett

Without seeing your data, try one of these

Sub sortrang()
Range(Range("a4"), Range("a4").End(xlDown).End(xlToRight)) _
..Sort Key1:=Range("A4"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
End Sub

Sub sortusedrange()
Range("a4").CurrentRegion _
..Sort Key1:=Range("A4"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top