Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() 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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
I want sort a list but the sort is unlit on the home tab how do I | Excel Worksheet Functions | |||
Sort with a List | Excel Worksheet Functions | |||
Excel sort by Fill Color by custom list sort | Excel Discussion (Misc queries) | |||
sort list of players by team from player list on separate sheet | Excel Worksheet Functions | |||
Can you sort a list based on catagory names without useing a custom list? | Excel Programming |