Results 1 to 3 of 3

Thread: randomly select a row from a excel sheet

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jun 2004
    Posts
    169

    randomly select a row from a excel sheet

    how to randomly select a row number from excel sheet? I am simulating lottery game.


    thx

  2. #2
    Hyperactive Member
    Join Date
    May 2001
    Location
    TZI Transition Date
    Posts
    272

    Re: randomly select a row from a excel sheet

    Dim RandomRow As Long
    'RandomRow = 'whatever code you'd use to pick a random number between 1 & 65536
    Rows(RandomRow).EntireRow.Select

  3. #3
    Hyperactive Member
    Join Date
    May 2001
    Location
    TZI Transition Date
    Posts
    272

    Re: randomly select a row from a excel sheet

    this works from in excel

    VB Code:
    1. Sub test()
    2.     Dim RandomRow As Long
    3.     Randomize
    4.     RandomRow = Int((65536 * Rnd) + 1)
    5.     Rows(RandomRow).EntireRow.Select
    6. End Sub

Posting Permissions

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



Click Here to Expand Forum to Full Width