IceBox Posted March 2, 2005 Report Share Posted March 2, 2005 I have worked with random numbers quite a bit, but one aspect has always puzzled me. And now I need to use that aspect... Basically, I need Macro Express to generate x/3 amount of unique random numbers out of a range from 1 to x. x will change daily. Let me put this into more concrete terms: I get an Excel file every day that has a variable amount of lines on it. I need to take 1/3 of those lines (at random) and copy them to another tab in that workbook. So if there are 240 lines, I need to copy 80 of them at random. Obviously, if I generate 80 random numbers, there is a chance that some numbers will duplicate and I need them to be all unique. Is there a way to generate unique random numbers? I have already programmed a macro that generates 2 unique random numbers using code similar to this: Variable Set Integer %N1% with a Random Number Repeat Until %N2% <> %N1% Variable Set Integer %N2% with a Random Number Repeat End This method worked great for just 2 numbers, but what about for 80? That could get REALLY long!!! Any help is much appreciated! Quote Link to comment Share on other sites More sharing options...
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.