Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 121
Default Sort Worksheet Range from another worksheet range, Excel 2000 & 2003

Hello,

In the same workbook I have two worksheets:

Worksheet 1 Range("D5:D55") is the range to sort Worksheet 2
Range("B4:C103").

Worksheet 1 - data

Column D
0125
0502
1250
2500

Worksheet 2 - data

Column B Column C
0125 Name 1
0502 Name 2
1250 Name 3
2500 Name 4

How can I use a macro to use worksheet 1 range to sort worksheet 2
range as described above?

Thank you for your help,
jfcby

  #2   Report Post  
Posted to microsoft.public.excel.programming
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

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
Why can't I repeat a sort on another range of a worksheet? DistantFlier Excel Worksheet Functions 0 January 19th 10 09:38 PM
Loop through Row Range, Excel 2000, 2003 jfcby[_2_] Excel Programming 19 December 24th 06 03:33 PM
Worksheet Range Question - Excel 2003 jfcby[_2_] Excel Programming 5 November 21st 06 09:01 PM
worksheet in excel 2000 different than 2003 StressMonkey Excel Discussion (Misc queries) 2 October 4th 06 02:59 PM
How do I sort a range of cells via a worksheet function RogerWilco Excel Worksheet Functions 3 January 11th 06 07:24 PM


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