+ Reply to Thread
Results 1 to 6 of 6

Selecting Random Lines from Data

  1. #1
    Registered User
    Join Date
    10-19-2012
    Location
    Solihull, UK
    MS-Off Ver
    Excel 2007
    Posts
    9

    Selecting Random Lines from Data

    Hello All,

    I am trying to resolve an issue in excel and am stumped... I have a set of data spanning across 400 rows and I want to somehow be able to have a macro to randomnly select say 40 rows of data and highlight it..

    Is this possible in Excel?

  2. #2
    Forum Expert Jakobshavn's Avatar
    Join Date
    08-17-2012
    Location
    Lakehurst, NJ, USA
    MS-Off Ver
    Excel 2007
    Posts
    1,970

    Re: Selecting Random Lines from Data

    See the attached workbook as an example.
    Attached Files Attached Files
    Gary's Student

  3. #3
    Valued Forum Contributor
    Join Date
    08-13-2012
    Location
    Gardony, Hungary
    MS-Off Ver
    Excel 2003
    Posts
    558

    Re: Selecting Random Lines from Data

    Here is my version. Run the macro and enter how many rows you want to choose.

    Edit: I took the function from Ozgrid. Thanks to whoever made it.

    Please Login or Register  to view this content.
    Last edited by RHCPgergo; 11-28-2012 at 09:54 AM. Reason: reference

  4. #4
    Registered User
    Join Date
    10-19-2012
    Location
    Solihull, UK
    MS-Off Ver
    Excel 2007
    Posts
    9

    Re: Selecting Random Lines from Data

    Hi,

    Sorry for the late response... I have tested both and they work a dream... I like the one from OzGrid as it gives me the ability to select the lines I wish to audit.

    I do have one questions though... The macro highlights the number of rows I require but I would want it highlight the rows... Would anyone know how to change the macro to colour the selected rows instead of highlighting them

  5. #5
    Valued Forum Contributor
    Join Date
    08-13-2012
    Location
    Gardony, Hungary
    MS-Off Ver
    Excel 2003
    Posts
    558

    Re: Selecting Random Lines from Data

    Hi,

    change this line at the end of the sub:
    Please Login or Register  to view this content.
    to this:
    Please Login or Register  to view this content.
    Change to ColorIndex to whatever you want from 1 to 56. Here's a key to which is which.
    http://dmcritchie.mvps.org/excel/colors.htm#colorindex
    Last edited by RHCPgergo; 11-28-2012 at 10:28 AM. Reason: oops

  6. #6
    Registered User
    Join Date
    10-19-2012
    Location
    Solihull, UK
    MS-Off Ver
    Excel 2007
    Posts
    9

    Re: Selecting Random Lines from Data

    Absolutely brilliant... Really appreciate the input... This works a dream now

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1