LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 48
Default Sort command

much smaller and quicker than mine. I'll use it from now on.

"Tom Ogilvy" wrote in message
...
code is untested and may contain typos:

Private Sub cmdOK_click() '< == OK
Dim rng As Range, rng1 As Range
Dim res As Variant
Dim rng2 As Range
With Worksheets("sheet1")
Set rng = .Range("A6:U55")
Set rng1 = .Range("A6:U6")
End With
res = Application.Match(combobox1.Value, rng1, 0)
If Not IsError(res) Then
Set rng2 = rng1(1, res)
rng.Sort Key1:=rng2, Order1:=xlAscending, _
Header:=xlYes, OrderCustom:=1, _
MatchCase:=False, Orientation:=xlTopToBottom
End if
Unload Me
End Sub


Private Sub Userform_Initialize
Dim rng As Range
With Worksheets("sheet1")
Set rng = .Range("A6:U6")
End With
for each cell in rng
Combobox1.AddItem cell.Value
Next
End With

Private Sub cmdCancel_Click()
Unload Me
End Sub

--
Regards,
Tom Ogilvy



Todd Huttenstine wrote in message
...
Hey guys,

I have a name in each cell from A6 through U6. The
objective is to be able to sort by each of these names. I
will use a form that will contain 3 objects: A DROP DOWN
BOX, OK button, and CANCEL button. I need for each name
in range A6:U6 to show up in the drop down box. I will
select a name from the drop down box and click the OK
button. When I click the OK button, I need it to sort
data in range A7:U55 by the name I selected from the drop
down box.

Can anyone tell me the code?

Thanx


Todd Huttenstine





 
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
Pivot Table Error Message - "Command Text not set for command obje Jeff Divian Excel Discussion (Misc queries) 0 November 7th 07 10:26 PM
Why is the sort command in excel 2003 shaded out? jico New Users to Excel 7 September 28th 06 06:05 PM
Sort command does not sort some columns? BillyBob New Users to Excel 4 May 11th 06 04:16 PM
how do i trace back my sort command on a column ????? rp Charts and Charting in Excel 1 December 1st 05 01:09 PM
sort command Lady Layla New Users to Excel 8 March 31st 05 04:54 PM


All times are GMT +1. The time now is 03:41 AM.

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

About Us

"It's about Microsoft Excel"