Private Sub Worksheet_SelectionChange(ByVal Target As Range)
On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range("A1:D1")) Is Nothing Then
With Target
If .Characters(Len(.Value), 1).Font.Name < "Marlett" Then
.Value = .Value & " t"
.Characters(Len(.Value), 1).Font.Name = "Marlett"
End If
If Right(.Value, 1) = "t" Then
.EntireColumn.Sort key1:=.Offset(1, 0), _
order1:=xlAscending, _
header:=xlYes
.Value = Left(.Value, Len(.Value) - 1) & "u"
.Characters(Len(.Value), 1).Font.Name = "Marlett"
Else
.EntireColumn.Sort key1:=.Offset(1, 0), _
order1:=xlDescending, _
header:=xlYes
.Value = Left(.Value, Len(.Value) - 1) & "t"
.Characters(Len(.Value), 1).Font.Name = "Marlett"
End If
.Offset(1, 0).Activate
End With
End If
ws_exit:
Application.EnableEvents = True
End Sub
This is worksheet event code, so put it in the sheet's code module.
Author unknown
Mike F
"m3s3lf" wrote in
message ...
Wrote:
Hi,
Maybe this site will help you:
www.oaltd.co.uk
and try to download quckshort.zip ,
there's algorithm sample using API
Rgds,
HAlim
m3s3lf menuliskan:
I've got some invisible rectanges that sit on top of my headers, so
when
somebody clicks on them, they sort based on that column. (All I did
was
assign some simple macros to each rectangle.) Anyhow, I would
really
like to be able to sort ascending with 1 click and descending with
another click. Does anybody have any ideas on how to accomplish
this?
Here's one of my sort macros:
Code:
--------------------
Sub ArchiveSortBySalePrice()
Range("ClosedSales").Sort Key1:=Range("D2"), Order1:=xlAscending,
Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
End Sub
That's very impressive... but way over my head! I'm only looking for a
couple lines of code. Can anybody else help?
Thank you!
--
m3s3lf
------------------------------------------------------------------------
m3s3lf's Profile:
http://www.excelforum.com/member.php...o&userid=34874
View this thread: http://www.excelforum.com/showthread...hreadid=564975