#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Sort list

I have a list that I fill from information from other sheets and then I want
to sort the list how would I do that. I have tried and can't seem to get
sort to work.

Here is my code.

Private Sub CommandButton1_Click()
Dim wrksht As Worksheet
Dim oListCol As ListRow
Dim oList As ListObject
Dim oListSort As ListColumn
Dim sWork As String
Dim ListRange As Range

Set wrksht = ActiveWorkbook.Worksheets("Reports")
Set oList = wrksht.ListObjects(1)
For Each lsheet In Sheets
If (lsheet.Name < "Reports") Or (lsheet.Name < "Panels List") Or
(lsheet.Name < "Master") Then
Set oListCol = wrksht.ListObjects("list1").ListRows.Add
sWork = "=text('" & lsheet.Name & "'!b2,""#"")"
oListCol.Range.Cells(1, 1).Value = sWork
oListCol.Range.Cells(1, 2).Formula = "='" & lsheet.Name & "'!b112"
oListCol.Range.Cells(1, 3).Formula = "='" & lsheet.Name & "'!c112"
oListCol.Range.Cells(1, 4).Formula = "='" & lsheet.Name & "'!b113"
oListCol.Range.Cells(1, 5).Formula = "='" & lsheet.Name & "'!c113"
oListCol.Range.Cells(1, 6).Formula = "='" & lsheet.Name & "'!b114"
oListCol.Range.Cells(1, 7).Formula = "='" & lsheet.Name & "'!c114"
oListCol.Range.Cells(1, 8).Formula = "='" & lsheet.Name & "'!b115"
oListCol.Range.Cells(1, 9).Formula = "='" & lsheet.Name & "'!c115"
End If
Next
' want to sort list box now on column 1
End Sub


Thanks
Kirk Groome


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Sort list


Hi Kirk,

You could try these, the first sorts column A in ascending forma
assuming no header to the column the second assumes a header to th
column.

hope they help!

Simon

Columns("A:A").Select
Selection.Sort Key1:=Range("A1"), Order1:=xlAscending
Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
_
DataOption1:=xlSortNormal

Columns("A:A").Select
Selection.Sort Key1:=Range("A2"), Order1:=xlAscending
Header:=xlYes, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
_
DataOption1:=xlSortNorma

--
Simon Lloy
-----------------------------------------------------------------------
Simon Lloyd's Profile: http://www.excelforum.com/member.php...nfo&userid=670
View this thread: http://www.excelforum.com/showthread.php?threadid=27677

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
I want sort a list but the sort is unlit on the home tab how do I chetrx Excel Worksheet Functions 3 November 14th 08 11:47 PM
Sort with a List Ray A Excel Worksheet Functions 0 September 7th 05 01:06 AM
Excel sort by Fill Color by custom list sort Dash4Cash Excel Discussion (Misc queries) 2 July 29th 05 10:45 PM
sort list of players by team from player list on separate sheet Robert Excel Worksheet Functions 1 July 19th 05 01:57 AM
Can you sort a list based on catagory names without useing a custom list? BobbyFlanigan Excel Programming 2 July 29th 04 02:49 AM


All times are GMT +1. The time now is 05:32 PM.

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"