ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   can I set up a sort command to happen by clicking on a table headi (https://www.excelbanter.com/excel-programming/344659-can-i-set-up-sort-command-happen-clicking-table-headi.html)

Aaron

can I set up a sort command to happen by clicking on a table headi
 
I have a table I would like to set up to be sorted by clicking on a table
heading. Is that possible in Excel?


Thank you.


Tom Ogilvy

can I set up a sort command to happen by clicking on a table headi
 
In Excel 2003 you can create a list and have functionality very similar to
this I believe.

--
Regards,
Tom Ogilvy


"Aaron" wrote in message
...
I have a table I would like to set up to be sorted by clicking on a table
heading. Is that possible in Excel?


Thank you.




JNW

can I set up a sort command to happen by clicking on a table headi
 
Let's assume that you have 3 headers in cells a1,b1, and c1. The following
are the steps to take:

1)Select a1
2) Insert Hyperlink
3) Choose "Place in this document"
4) type the activecell's address in the "Type the cell reference" box (a1 in
this instance)
5) Click OK
6) Repeat this for all headers substituting the correct cell reference
7) Write (or record) macros to sort based on each heading
8) Right-Click on the table's sheet tab and select "View Code"
9) Paste the following:

Private Sub Worksheet_FollowHyperlink(ByVal TArget As Hyperlink)
If Not Intersect(Target.Parent, Range("A1")) Is Nothing Then
SortA1 'replace with the name of you sub to sort the first column
end if

if Not Intersect(Target.Parent, Range("B1")) Is Nothing Then
SortB1 'again replace with appropriate sub
end if
'continue for all headings that you have

end sub

hope that helps. I found this on another post in this NG called "Can a
Hyperlink run a macro?" I searched for "hyperlink for macro" to find it.

JNW

"Aaron" wrote:

I have a table I would like to set up to be sorted by clicking on a table
heading. Is that possible in Excel?


Thank you.



All times are GMT +1. The time now is 07:01 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com