![]() |
How to use Header "Text" as Sort Key
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. |
How to use Header "Text" as Sort Key
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. |
How to use Header "Text" as Sort Key
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. |
All times are GMT +1. The time now is 05:23 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com