Closed Thread
Results 1 to 7 of 7

Macro to find Name, Select (random) corresponding value

  1. #1
    Registered User
    Join Date
    02-14-2020
    Location
    california
    MS-Off Ver
    2013
    Posts
    10

    Macro to find Name, Select (random) corresponding value

    Hello,

    i've been tasked with creating a macro to determine if a name is present in a list, and if it is present - randomly select a value(case) corresponding to that person from another column. So for example, in the sample data i pasted below, how to find if Will is present, then randomly select one of his cases? any assistance would be much appreciated


    Cases EmpIDs
    CA70914 Will
    CA11254 Will
    CA75853 Jill
    CA69664 Jim
    CA87459 Jim
    CA72493 Jess
    CA73302 Mike
    CA74037 Bill
    CA74791 Will
    CA78075 Grant
    CA74436 Karen
    CA75873 Alice
    CA75266 Nora

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Macro to find Name, Select (random) corresponding value

    This will give you the base code to play with, you will need to work out the logistics of where the data is coming from and the input of the name "Will". But this shows you a technique.

    Please Login or Register  to view this content.
    Last edited by JBeaucaire; 02-14-2020 at 04:55 PM.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Registered User
    Join Date
    02-14-2020
    Location
    california
    MS-Off Ver
    2013
    Posts
    10

    Re: Macro to find Name, Select (random) corresponding value

    Thanks JB really helpful! is there a way to have this start with an input box so the user can input a name to search?

  4. #4
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Macro to find Name, Select (random) corresponding value

    Like so, edits in red:

    Please Login or Register  to view this content.

  5. #5
    Valued Forum Contributor
    Join Date
    02-02-2016
    Location
    Indonesia
    MS-Off Ver
    Office 365
    Posts
    1,003

    Re: Macro to find Name, Select (random) corresponding value

    Just another way:
    Please Login or Register  to view this content.
    Note:
    If you have a lot of unique names, say tens or hundreds, on the list then I suggest you use a combobox, so you can choose a name instead of typing. Typing names is prone to errors.

  6. #6
    Registered User
    Join Date
    02-14-2020
    Location
    california
    MS-Off Ver
    2013
    Posts
    10

    Re: Macro to find Name, Select (random) corresponding value

    thank JB, this is amazing! If I had a date column, how would I get that to appear in the MSG box as well? For example; the Msgbox returns Random Case CA12345, date 12/5/2019 .... thank you so much

  7. #7
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2404 Win 11 Home 64 Bit
    Posts
    23,865

    Re: Macro to find Name, Select (random) corresponding value

    Closed. This request has been opened in Commercial Services
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

Closed Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Assigning a Macro to Select a Random Name
    By TheShadow93 in forum Excel General
    Replies: 4
    Last Post: 05-03-2017, 06:11 AM
  2. Macro Help - Random Select
    By Silkk in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-16-2015, 12:37 PM
  3. Macro to select 10 random records from list with 2 filters
    By Iceman1988 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-02-2013, 01:17 PM
  4. Random Select Macro - Compile Error: Sub or Function not defined.
    By SalientAnimal in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-29-2013, 04:46 AM
  5. Find then select row macro
    By deluxe01 in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 09-01-2009, 02:35 PM
  6. Find then select row macro
    By deluxe01 in forum Outlook Programming / VBA / Macros
    Replies: 0
    Last Post: 08-27-2009, 03:01 PM
  7. How do I find random number in list of random alpha? (Position is.
    By jlahealth-partners in forum Excel General
    Replies: 0
    Last Post: 02-08-2005, 02:06 PM

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