Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Need help with sorting, please.


i really need help w/ this sorting problem i'm having...

consider the following:

Sub SortBy()
Application.ScreenUpdating = False
Range("a1:aa1218").Select
Selection.Sort Key1:=Range("a1"), Order1:=xlAscending, Header:=xlYes
_
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
Range("a1").Select
Application.ScreenUpdating = True
End Sub

i have that code on an option button
i have columns a:aa
every column except i:p has an option button over it's colum
heading...
(e.g. E1 is "description" and there's an option button there, R1 i
state, and so on...)

now, i can make 20-some macros based on the option button you selec
but i was hoping there's a way i can have 1 macro that if i select th
option button in col Q it will sort by Q, etc etc...

please, any help would mean a great deal..

-----------------------------------------------
~~ Message posted from http://www.ExcelTip.com
~~View and post usenet messages directly from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,089
Default Need help with sorting, please.

One way:

Sub SortBy()
Application.ScreenUpdating = False
' select the cell before running the macro
Range("a:aa").Sort _
Key1:=ActiveCell, _
Order1:=xlAscending, _
Header:=xlYes, _
OrderCustom:=1, _
MatchCase:=False, _
Orientation:=xlTopToBottom
Application.ScreenUpdating = True
End Sub

Regards

Trevor


"aapp81" wrote in message
...

i really need help w/ this sorting problem i'm having...

consider the following:

Sub SortBy()
Application.ScreenUpdating = False
Range("a1:aa1218").Select
Selection.Sort Key1:=Range("a1"), Order1:=xlAscending, Header:=xlYes,
_
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
Range("a1").Select
Application.ScreenUpdating = True
End Sub

i have that code on an option button
i have columns a:aa
every column except i:p has an option button over it's column
heading...
(e.g. E1 is "description" and there's an option button there, R1 is
state, and so on...)

now, i can make 20-some macros based on the option button you select
but i was hoping there's a way i can have 1 macro that if i select the
option button in col Q it will sort by Q, etc etc...

please, any help would mean a great deal...


------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~View and post usenet messages directly from http://www.ExcelForum.com/



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default Need help with sorting, please.

If you can live with just a tiny macro for each button here is what I came
up with.


Public tt As Range
Sub Button1_click()
Set tt = Range("A1")
Call SortBy
End Sub
Sub Button2_click()
Set tt = Range("B1")
Call SortBy
End Sub
Sub Button3_click()
Set tt = Range("C1")
Call SortBy
End Sub
'continue on with just a small macro for each button

Sub SortBy()
a = tt.Column
MsgBox tt.Address & "sortby macro"
Application.ScreenUpdating = False
Range(Cells(1, a), Cells(1218, a)).Activate
Selection.Sort Key1:=tt, Order1:=xlAscending, Header:=xlYes, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
tt.Select
Application.ScreenUpdating = True

End Sub



"aapp81" wrote in message
...

i really need help w/ this sorting problem i'm having...

consider the following:

Sub SortBy()
Application.ScreenUpdating = False
Range("a1:aa1218").Select
Selection.Sort Key1:=Range("a1"), Order1:=xlAscending, Header:=xlYes,
_
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
Range("a1").Select
Application.ScreenUpdating = True
End Sub

i have that code on an option button
i have columns a:aa
every column except i:p has an option button over it's column
heading...
(e.g. E1 is "description" and there's an option button there, R1 is
state, and so on...)

now, i can make 20-some macros based on the option button you select
but i was hoping there's a way i can have 1 macro that if i select the
option button in col Q it will sort by Q, etc etc...

please, any help would mean a great deal...


------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~View and post usenet messages directly from http://www.ExcelForum.com/



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
Sorting Values Without Sorting Formulas SBX Excel Discussion (Misc queries) 2 April 12th 09 11:17 PM
Automatic sorting (giving max and min) based on custom sorting lis Joe Lewis[_2_] Excel Worksheet Functions 4 November 23rd 08 05:12 AM
Sorting VLookup vs Sorting SumProduct Lauren Excel Discussion (Misc queries) 1 August 21st 07 12:19 AM
Sorting: Sorting by the First Character dzuy Excel Discussion (Misc queries) 2 June 22nd 06 08:27 PM
Sorting ListBox results or transposing ListBox values to other cells for sorting Rob[_8_] Excel Programming 1 July 9th 03 04:35 AM


All times are GMT +1. The time now is 08:55 PM.

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"