View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
jfcby[_2_] jfcby[_2_] is offline
external usenet poster
 
Posts: 121
Default Sort Worksheet Range from another worksheet range, Excel 2000 & 2003

Hello,

Thank you for your help!

Problem has been solved with the help of a co-worker and the macros
below:

[EXTRA INFO: If you want to run a macro to create a Custom List
follow these directions
.......Go To - TOOLS MACROS RECORD NEW MACRO OK
1. In a range of cells, enter the values you want to sort by, in the
order you want them, from top to bottom.
For example:
DATA
High
Medium
Low
2. Select the range.
3. On the TOOLS menu, click OPTIONS, and then click the CUSTOMS LISTS
tab.
4. Click IMPORT, and then click OK.
5. Select a cell in the range you want to sort.
6. On the DATA menu, click SORT.
7. In the SORT BY box, click the column you to sort.
8. Click OPTIONS.
9. Under FIRST KEY SORT ORDER, click the list you created. For
example, click HIGH, MEDIUM, LOW.
10. Click OK.
11. Select any other sort options you want, and then click OK.
NOTE: You can't use a custom sort order in a THEN BY box. The custom
sort order applies only to the column specified in the SORT BY box. To
sort multiple columns by using a custom sort order, sort by each
column separately. For example, to sort by columns A and B, in the
order, first sort by column B, and then specify the custom sort by
using the SORT OPTIONS dialog box. Next, sort the range by column A.
.......click STOP RECORDING button
<<]

Macro 1: SortRangeExampleB - Sorts Range from an Array Range same
Worksheet

'--
Sub SortRangeExampleB()
'Sorts Range from an Array Range same Worksheet
Dim myArr As Variant
Dim myListNumber As Long
'--
myArr = Range("H1:H11")
Application.AddCustomList ListArray:=myArr
myListNumber = Application.GetCustomListNum(myArr)
'--
Range("G1:G11").Select
'--
Selection.Sort Key1:=Range("G1"), Order1:=xlAscending, _
Header:=xlGuess, OrderCustom:=myListNumber + 1
'--
Application.DeleteCustomList myListNumber
End Sub
'<<--<<

Macro 2: SortRangeExampleC - Sorts Range from an Array Range separate
Worksheets

'--
Sub SortRangeExampleC()
'Sorts Range from an Array Range separate Worksheets
Dim myArr As Variant
Dim myListNumber As Long
'--
myArr = Worksheets("MACROS").Range("H1:H11") 'change worksheet &
range
Application.AddCustomList ListArray:=myArr
myListNumber = Application.GetCustomListNum(myArr)
'--
Worksheets("Activate Macro Buttons").Select 'change worksheet
Worksheets("Activate Macro Buttons").Range("G1:G11").Select 'change
worksheet & range
'-- change worksheet & range
Selection.Sort Key1:=Worksheets("Activate Macro
Buttons").Range("G1"), Order1:=xlAscending, _
Header:=xlGuess, OrderCustom:=myListNumber + 1
'--
Application.DeleteCustomList myListNumber
End Sub
<<--

Thank you for your help,
jfcby