View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Don Guillett Don Guillett is offline
external usenet poster
 
Posts: 10,124
Default Macro Button to Sort Columns - Troubleshooting ideas?

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

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Munchkin" wrote in message
...
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