Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default How do I alternate a sort from a text box via macros?

I have a column of data that I am using a text box to run a macro that sorts
the data in descending order. How can I alternate the sort criteria
(ascending/descending) using the same text box? Push once - sort in
ascending order; push again - sort in descending order. Thanks.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 692
Default How do I alternate a sort from a text box via macros?

Here's a down and dirty method

Dim x As Long, ordr As Long

x = MsgBox("Sort Ascending (Yes), Descending (No)", vbYesNo)

If x = 6 Then ' 6 = Yes
ordr = 1 ' 1 = ascending
Else
ordr = 2 ' 2 = descending
End If

Range("E:E").Sort Key1:=Range("E1"), Order1:=ordr, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom


--
steveB

Remove "AYN" from email to respond
"g.a." wrote in message
...
I have a column of data that I am using a text box to run a macro that
sorts
the data in descending order. How can I alternate the sort criteria
(ascending/descending) using the same text box? Push once - sort in
ascending order; push again - sort in descending order. Thanks.



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macros Automatically Sort Fran Excel Worksheet Functions 3 May 21st 09 11:45 PM
Excell Dropdown List. Display alternate text than found in list. Shawnn Excel Discussion (Misc queries) 14 December 11th 08 07:43 PM
Macros and sort function TimJ Excel Worksheet Functions 1 August 28th 07 08:18 PM
How do I alternate a sort from a text box via macros? g.a. Excel Programming 0 June 9th 05 06:03 AM
Button Code to Alternate Sort Order ? Paul Cross Excel Programming 1 November 13th 04 12:37 AM


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

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"