Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Sort Code Modification

I have the following working code to sort the range of data by the value in
combobox1.

Using the following code, what adjustments do I need to make to get it to
sort all the data by Ext?

Private Sub CommandButton2_Click()
'Sorts by the stat you select in the combobox.
'Sorts all data in the range A4:Z100

Dim Rng As Range, rng1 As Range
Dim res As Variant
Dim rng2 As Range
With Worksheets(1)
Set Rng = .Range("A4:Z100")
Set rng1 = .Range("A4:Z4")
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



Thanx
Todd Huttenstine


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 473
Default Sort Code Modification

Todd Huttenstine(Remote) wrote:
Using the following code, what adjustments do I need to make to get it to
sort all the data by Ext?


I assume "Ext" is the heading of a field somewhere in A4:Z4?

res = Application.Match("Ext", rng1, 0)

Bill Manville
MVP - Microsoft Excel, Oxford, England
No email replies please - reply in newsgroup

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
modification to this code James Excel Discussion (Misc queries) 0 March 23rd 09 09:20 PM
Code modification help AndyMP Excel Worksheet Functions 1 February 8th 09 11:41 PM
line code modification TUNGANA KURMA RAJU Excel Discussion (Misc queries) 3 March 2nd 07 01:12 PM
Code Modification(From previous post) Todd Huttenstine[_2_] Excel Programming 1 November 4th 03 02:29 AM
Modification to code Peter Atherton Excel Programming 1 September 23rd 03 07:36 PM


All times are GMT +1. The time now is 10:43 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"