Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default How can I sort contents of one column based on the contents ofanother column?

I have some data in column "A" and random numeric values in column
"B".
I want to sort column "A" based on the ascending order of column "B".
I was able to do it manually by selecting both the columns and
sorting. But i dont know how to do it in a macro...
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,942
Default How can I sort contents of one column based on the contents of ano

hi
Dim r As Range
Set r = Range("A1", Range("A1").End(xlDown).Offset(0, 1))

r.Sort Key1:=Range("B1"), Order1:=xlAscending, _
Header:=xlGuess, OrderCustom:=1, MatchCase:=False, _
Orientation:=xlTopToBottom, DataOption1:=xlSortNormal

when ever you hit a syntax snag, do what i do. turn on the recorder and
perform the desired actions manually. most of the time, the recorder will
show you the basic syntax and give you a basic idea of how to code it.
sometimes editing is reguired but you do get the basic idea. very helpful for
people just starting out.

Regards
FSt1

" wrote:

I have some data in column "A" and random numeric values in column
"B".
I want to sort column "A" based on the ascending order of column "B".
I was able to do it manually by selecting both the columns and
sorting. But i dont know how to do it in a macro...

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
Fill a column with the contents of another column based on a choic Sparky56 Excel Discussion (Misc queries) 1 March 31st 07 04:18 AM
Button To Sort Sheet Contents On Column? (PeteCresswell) Excel Programming 6 February 9th 07 03:43 PM
Fill in contents based on another column asra Excel Programming 1 February 2nd 06 07:03 PM
Fill in contents based on another column asra Excel Worksheet Functions 1 February 2nd 06 06:40 PM
move contents of column C based on criteria related to column A Debra Excel Discussion (Misc queries) 2 December 27th 05 10:25 PM


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