Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default code for sort until cell equals...

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default code for sort until cell equals...

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
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
Have the need to sort text code-values within same Excel cell A.X M.D Excel Worksheet Functions 2 December 3rd 09 07:26 PM
If a cell equals _, at the next row that equals _, return value fr CathyH Excel Worksheet Functions 10 May 2nd 07 07:53 PM
If cell is left blank, or equals zero, then cell equals a different cell John McMurry Excel Discussion (Misc queries) 3 April 13th 07 01:14 PM
if a:a (range) equals january and c:c equals gas then add g:g ($) BCOz Excel Worksheet Functions 4 December 29th 05 07:40 PM
custom filter does not work when selecting 'equals' X AND 'equals' plindman Excel Discussion (Misc queries) 1 June 1st 05 11:29 PM


All times are GMT +1. The time now is 04:34 PM.

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"