PC Review


Reply
Thread Tools Rate Thread

code for sort until cell equals...

 
 
A
Guest
Posts: n/a
 
      10th Apr 2009
Hi -

I have two lists that I'm randomizing by sorting each one with a
column of =rand(). The lists both contain negative and positive words.
If a positive word is in list 1 and a negative in list 2, let's call
that 1pos-2neg. I need to have an even number of 1pos-2pos,
1pos-2neg, 1neg-2pos, and 1neg-2neg.

So I have a countif cell that determines the number of 1pos-2pos I
have and another countif cell that tells me how many 1pos-2neg I have
and so on. Then an "if" formula says all the countif cells have to be
the same and if they are it says "MATCH". Then I just keep sorting
until this cell says "MATCH."

Is there any excel code that basically says "After selecting columns M
and N, keep sorting column N until cell AA22 says "MATCH"?

Any help would be greatly appreciated.

A
 
Reply With Quote
 
 
 
 
A
Guest
Posts: n/a
 
      10th Apr 2009
Look like I figured it out.. pretty easy otherwise I wouldn't have
been able to get it

Thanks.

Sub Macro1()
Dim r As Range
Dim Rng As Range
Set r = Range("AA22")
Set Rng = Range("M:N")
Do
Rng.Sort _
Key1:=Range("N:N"), _
Order1:=xlAscending, _
Header:=xlYes, _
OrderCustom:=1, _
MatchCase:=False, _
Orientation:=xlTopToBottom
Loop Until r = "MATCH"
End Sub
 
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
Have the need to sort text code-values within same Excel cell A.X M.D Microsoft Excel Worksheet Functions 2 3rd Dec 2009 07:26 PM
If a cell equals _, at the next row that equals _, return value fr =?Utf-8?B?Q2F0aHlI?= Microsoft Excel Worksheet Functions 10 2nd May 2007 07:53 PM
If cell is left blank, or equals zero, then cell equals a different cell John McMurry Microsoft Excel Misc 3 13th Apr 2007 01:14 PM
How to create/run "cell A equals Cell B put Cell C info in Cell D =?Utf-8?B?YWJtYjE2MQ==?= Microsoft Excel Misc 5 26th Jan 2006 06:36 PM
Cell CODE equals #VALUE! =?Utf-8?B?SkM=?= Microsoft Excel Worksheet Functions 3 24th Mar 2004 02:51 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:25 AM.