Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
How can I use the text within a header cell as a sort key?
For example, ActiveSheet.Range("A1").CurrentRegion _ .Sort Key1:="DATE", Order1:=xlDescending, _ Key2:="LOCATION", Order2:=xlAsending, Header:=xlYes Thank you. |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
this worked for me, if that's what you're asking:
Sub test() Dim key2 As String key2 = Range("b1").Value With Worksheets("Sheet1").Range("A1:b10").CurrentRegion .Sort Key1:="DATE", Order1:=xlDescending, _ key2:=key2, Order2:=xlAscending, Header:=xlYes End With End Sub -- Gary "Bassman62" wrote in message ... How can I use the text within a header cell as a sort key? For example, ActiveSheet.Range("A1").CurrentRegion _ .Sort Key1:="DATE", Order1:=xlDescending, _ Key2:="LOCATION", Order2:=xlAsending, Header:=xlYes Thank you. |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thank you.
I see that it works better to use the "With" statement. Dave "Gary Keramidas" wrote: this worked for me, if that's what you're asking: Sub test() Dim key2 As String key2 = Range("b1").Value With Worksheets("Sheet1").Range("A1:b10").CurrentRegion .Sort Key1:="DATE", Order1:=xlDescending, _ key2:=key2, Order2:=xlAscending, Header:=xlYes End With End Sub -- Gary "Bassman62" wrote in message ... How can I use the text within a header cell as a sort key? For example, ActiveSheet.Range("A1").CurrentRegion _ .Sort Key1:="DATE", Order1:=xlDescending, _ Key2:="LOCATION", Order2:=xlAsending, Header:=xlYes Thank you. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Missing sort ascending or descending when go into "data" "sort"? | Excel Discussion (Misc queries) | |||
How to keep "Header Row" button checked during Sort | Excel Discussion (Misc queries) | |||
Listbox header inside VBA (Array("Head1", "Head2", ...) | Excel Programming | |||
How do I display the "ampersand" in the header as text | Setting up and Configuration of Excel | |||
Insert "-" in text "1234567890" to have a output like this"123-456-7890" | Excel Discussion (Misc queries) |