Please Help with Excel Sorting Macro!!

T

ticketopia

Help!!! I need a macro that will sort data by a column when the user
clicks on the column heading (i.e., username).

The macro then needs to return the user to the cell that was selected
prior to sorting the data.

Oh yeah, and I need it within a 1/2 hour.......

Puhleeeeeeaase help me!!!!!

Thanks so much!!
 
D

Don Guillett

Right click on the sheet tab>view code>insert this>save workbook.
name your range to be sorted as sortrange
Double click on any column to sort by that column.

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Excel.Range, Cancel
As Boolean)
[sortrange].Sort Key1:=Cells(1, activecell.column), Order1:=xlAscending,
Orientation:=xlTopToBottom
SendKeys "^{home}"
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