LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Controlling random rows

Hi Group,

I use code (attached below) to randomise 381 rows, which
then allows Solver to produce a random fantasy football
team. It works very well but I am looking to add
a 'feature' to my Solver routine so that is produces a
team with 'preferred' players. I've tried working out a
solution on my own but I come against Solver's 200
changing cells limit and was looking for some expert help
or advice.

Here's my problem...let's say I want a player called Van
Nistelrooy (Man U fan BTW) in my team. After the random
code kicks in, if Van Nistelrooy is not randomised into
the top 200 rows (Solver's limit) Solver cannot produce a
team with my preferred player.

Is it possible to add code after the random code to check
the cells (Y2:Y6) of my preferred players and, if there
are preferred players, somehow check my rows (A6:E381) to
find these players and cut and paste these to the top of
my list. That way, Solver will produce a team with my
preferred players in as they will be in the top 200 rows.
(ColA contains the name of each player.)

Will be glad of any help

Tony

'Random code start
Public Sub shuffle()

Dim RndCol(380, 0)
Dim i
Randomize
Application.ScreenUpdating = False
ActiveSheet.Columns(8).Insert
For i = 0 To UBound(RndCol, 1)
RndCol(i, 0) = Rnd
Next i
Range(Cells(6, 8), Cells(381, 8)) = RndCol
ActiveSheet.Range("a6:h381").Sort _
Key1:=ActiveSheet.Columns("H")
ActiveSheet.Columns(8).Delete
Application.ScreenUpdating = True

End Sub
'Random code end

 
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
Pivot Table - Controlling how many rows of data are displayed in t kirc Excel Discussion (Misc queries) 1 February 20th 09 05:03 PM
How to Set Range to 50 Random nonsequencial rows? [email protected] Excel Discussion (Misc queries) 6 March 19th 07 03:37 PM
Random Sampling rows [email protected] Excel Discussion (Misc queries) 2 March 16th 06 06:03 AM
How can I make the rows go into a random order? chicken99 Excel Worksheet Functions 6 March 2nd 06 12:02 AM
Controlling odd even rows when pasting data [email protected] Excel Discussion (Misc queries) 1 February 23rd 05 07:11 PM


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