+ Reply to Thread
Results 1 to 6 of 6

Random selection of cell for every unique username in column A

  1. #1
    Registered User
    Join Date
    09-13-2021
    Location
    India
    MS-Off Ver
    365
    Posts
    36

    Post Random selection of cell for every unique username in column A

    Hi Guys,

    Can someone help to build a VBA macro for the below requirement. Your help is much appreciated; thank you for looking into it.

    Below is the sample data sheet ("Sheet1")

    UserName ReportID
    Jerry 238894
    Jerry 239400
    Tom 389439
    Jerry 248392
    Hendry 938270
    Hendry 563820

    Expected output sheet ("Sheet2")

    UserName ReportID
    Jerry 239400
    Tom 389439
    Hendry 938270

    To note:
    1) This macro would be run one time per day.
    2) The "ReportID" will be different each day.
    3) The "UserName" will also vary (i.e name and no. of times it is mentioned).
    4) Each time the macro is run; the "ReportID" should be picked in a random basis. (i.e, day 1: UserName Jerry's 2nd ReportID picked; day 2: UserName Jerry's 1st ReportID picked).
    5) "UserName" should be coded as case-insensitive in macro.

    Can you please help writing a macro code for the above requirement. Thank you.
    Last edited by Lona; 01-04-2023 at 07:53 AM.

  2. #2
    Registered User
    Join Date
    04-07-2019
    Location
    Turkey-Ankara-Çubuk
    MS-Off Ver
    Office 2010
    Posts
    52

    Re: Random selection of cell for every unique username in column A

    Hi, try this.
    Please Login or Register  to view this content.
    Last edited by veyselemre; 01-04-2023 at 06:14 AM.

  3. #3
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: Random selection of cell for every unique username in column A

    Quote Originally Posted by Lona View Post
    4) Each time the macro is run; the "ReportID" should be picked in a random basis. (i.e, day 1: UserName Jerry's 2nd ReportID picked; day 2: UserName Jerry's 1st ReportID picked).
    If you want it like that, it is not RANDOM.
    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    09-13-2021
    Location
    India
    MS-Off Ver
    365
    Posts
    36

    Re: Random selection of cell for every unique username in column A

    Thank you very much, the code worked perfectly well..

  5. #5
    Registered User
    Join Date
    09-13-2021
    Location
    India
    MS-Off Ver
    365
    Posts
    36

    Re: Random selection of cell for every unique username in column A

    Quote Originally Posted by jindon View Post
    If you want it like that, it is not RANDOM.
    Please Login or Register  to view this content.
    This code worked well for me too; but it was case sensitive. Example: Jack vs jack; macro considered it to be different. Thank you so much for taking the time to respond.

  6. #6
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: Random selection of cell for every unique username in column A

    If you want it as case insensitive then add one line in bold
    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Random selection option, same 'random' selection in two columns
    By applebanana in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 02-01-2016, 06:16 PM
  2. [SOLVED] Random selection from a column of data
    By demarc in forum Excel General
    Replies: 8
    Last Post: 05-26-2015, 09:25 AM
  3. Replies: 2
    Last Post: 11-06-2014, 05:07 PM
  4. Random selection of rows for each unique value in a column
    By tin0989 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-18-2012, 10:36 AM
  5. Replies: 10
    Last Post: 12-21-2010, 06:14 PM
  6. Random selection with multiple column criteria
    By kleick in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 09-03-2009, 03:50 PM
  7. Replies: 4
    Last Post: 02-06-2009, 11:18 PM

Tags for this Thread

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