PC Review


Reply
Thread Tools Rate Thread

How can I sort contents of one column based on the contents ofanother column?

 
 
yajiv.vijay@gmail.com
Guest
Posts: n/a
 
      9th Feb 2008
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 With Quote
 
 
 
 
FSt1
Guest
Posts: n/a
 
      9th Feb 2008
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

"(E-Mail Removed)" 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 With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Sort listbox contents based on individual column ? mscertified Microsoft Access Form Coding 1 13th Nov 2008 04:14 AM
Using Data Validation in one column, based on contents of second column webinsomniac@gmail.com Microsoft Access Form Coding 2 14th Jul 2007 06:08 AM
move contents of column C based on criteria related to column A =?Utf-8?B?RGVicmE=?= Microsoft Excel Misc 2 27th Dec 2005 10:25 PM
Column E cell contents added into Column D contents (not overwriting data but mixing) creativetechguy Microsoft Excel Misc 2 5th Aug 2004 07:32 PM
Summing the contents of one column based on the contents of another? redmist Microsoft Excel Misc 5 6th Jan 2004 05:58 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:08 AM.