Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sort data section - EXCEPT for total row?

Status
Not open for further replies.

fbermudez

Technical User
Oct 22, 2003
14
0
0
US
I have a report that needs to be sorted by different columns depending on the end user.
I wrote a macro that shows the column name and a button so the end user can select the column they wish to sort on - Descending or Ascending Value

My problem is that I want to select everything between row 1 - the header row and row xxxx the total row to sort. row xxxx varies depending on when the report is run - so you can't hardcode the row number.

I ve tried:
Range("A2").Select -- selects 1st cell
Application.SendKeys "+^{end}" Ctrl+Shift+End Application.SendKeys "+{up}"to select the data range but it does not work

any ideas are greatly appreciated.

 
fbermudez,

Did you check out my post in the Office Forum?

If you want to try some codeing...
Code:
    With [A1].CurrentRegion
        Range(Cells(1, 1), Cells(.Rows.Count - 1, .Columns.Count)).Sort _
            Key1:=Range("A2"), Order1:=xlAscending, _
            Header:=xlYes, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
    End With
:)


Skip,

Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top