+ Reply to Thread
Results 1 to 10 of 10

Replace all names with random names

  1. #1
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    3,952

    Replace all names with random names

    When I post in a forum, or sometimes send out a report, I frequently need to replace names in a column with bogus names. I have a macro that does that for my management names (see below). I'd like make this a lot more flexible, and replace every name in a column with a bogus name. I would be satisified with even using incremental replacements, IE: I have a list of, say, 25 unique replacement values. If the first name is "Minnie", after using the other 24, it could start over with "Minnie1", then later "Minnie2", etc. Or, I could create a spreadsheet with thousands of unique goofy names, and use this for a lookup to replace my names in my column. Either way would work for me.

    I'd appreciate any help or advice you can share.

    Thanks,
    John
    Please Login or Register  to view this content.

  2. #2
    Forum Expert Tinbendr's Avatar
    Join Date
    06-26-2012
    Location
    USA
    MS-Off Ver
    Office 2010
    Posts
    2,125

    Re: Replace all names with random names

    Not tested.

    Please Login or Register  to view this content.
    What I do is go to a random name generator (there are numerous ones on the web) and pull 100 randoms first names, then 100 random last names and stick them in a spreadsheet. Then I concatenate the First/Last into Column C. Then I have a ready supply of random names.
    David
    (*) Reputation points appreciated.

  3. #3
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    3,952

    Re: Replace all names with random names

    David,

    I got a "type mismatch" on "For I = 0 To Selection.Rows"

    UPDATE: I corrected it by adding ".Count" after ".Rows". Now the macro runs, but I get no results (no changes).

    I also have a random name generator, which I could use to copy/paste over my column. But there are blanks in my columns, and I'd want to leave them blank. As well, I'd like some consistency in my column; if "Roger Ebert" exists 20 times in my column, I'd like whatever name replaces him in the first place to be the replacement in all the rest.
    Last edited by jomili; 08-16-2012 at 10:12 AM.

  4. #4
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: Replace all names with random names

    jomili,

    Assuming the selection only contains names you want to replace, give this a try:
    Please Login or Register  to view this content.
    Hope that helps,
    ~tigeravatar

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  5. #5
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    3,952

    Re: Replace all names with random names

    Hmmm...,

    Tigeravatar, your macro works, with some caveats. It's slow with a large range;my test range is 11K rows, and it took 59 seconds to do it all (this is after turning off Screenupdating). It did a great job skipping the blanks, and each name is unique, but I'd sure like to add some variety to the names. Name1, Name2, Name3 just isn't real exciting. But, it will definitely work in a pinch. Thanks for it.

  6. #6
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: Replace all names with random names

    jomili,

    Create a workbook to contain the fake names. That workbook should only have 1 sheet, and the fake names should start in A1 and go down column A with no blanks. Then use this code and update the strDummyNameFilePath to the correct file path and file name. I tested it on 48000 rows of names, and it completed in just over 41 seconds:
    Please Login or Register  to view this content.
    Last edited by tigeravatar; 08-16-2012 at 12:33 PM. Reason: Removed unnecessary NameIndex variable from code

  7. #7
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    3,952

    Re: Replace all names with random names

    This looks good, but do I need to have as many Dummy Names as real names in the list, or will the macro reuse the list?

  8. #8
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: Replace all names with random names

    Oh, I forgot about that part, give a me a sec to update it so it will reuse the list

    ---------- Post added at 10:46 AM ---------- Previous post was at 10:41 AM ----------

    Updated code:
    Please Login or Register  to view this content.

  9. #9
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    3,952

    Re: Replace all names with random names

    Tigr,
    Sorry it took me so long to get back to you. The macro works beautifully. It's slow when I do 11K+ rows, but some of that may be because my Random Names are generated from RAND functions when the workbook is opened. Thank you so much for your help on this!

  10. #10
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: Replace all names with random names

    You're very welcome

+ 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