+ Reply to Thread
Results 1 to 7 of 7

Replace cell contents with portion of cell contents

  1. #1
    Registered User
    Join Date
    11-15-2010
    Location
    Arlington, VA
    MS-Off Ver
    Excel 365
    Posts
    34

    Replace cell contents with portion of cell contents

    Hopefully I'm not a moocher, but for my second request this week, similar to my previous thread (https://www.excelforum.com/excel-pro...ml#post5194089), I use a software package that spits out some data that I need in a different format. Rick Rothstein kindly provided a small macro to reformat some text strings into a proper, usable time format. I have been poking at that code trying to understand it and repurpose it into this problem, but I'm stuck because ... well I believe his code changes some characters around then defines what format the numbers should be in. This works perfectly for numbers that have defined formats, but not text strings like what I'm working with.

    Basically, I am given employee names in a format "nnnn - Lastname, Firstname" (with nnnn being a badge #), but I need it in FirstInitial. Lastname format. I have been using a formula to do this:

    Please Login or Register  to view this content.
    This formula works for hypenated last names as well as multiple names as one would find in a Hispanic country (Jorge Francisco Lopez Gonzales, for example, where there is no clear middle name but multiple words in a name, shown as "Firstinitial. Name1 Name2 Name3".

    Thanks in advance for any advice.

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

    Re: Replace cell contents with portion of cell contents

    Welcome to the forum

    Please attach a sample workbook (not a picture or pasted copy). Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window.
    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

  3. #3
    Registered User
    Join Date
    11-15-2010
    Location
    Arlington, VA
    MS-Off Ver
    Excel 365
    Posts
    34

    Re: Replace cell contents with portion of cell contents

    I've gone ahead and posted the workbook that I keep just so I can copy the formula ... Column F represents what I'm starting with, Column G represents the result I'm looking for ... but I would like the macro to replace F with the format of G without having to insert columns.
    Attached Files Attached Files

  4. #4
    Valued Forum Contributor
    Join Date
    12-14-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2007
    Posts
    439

    Re: Replace cell contents with portion of cell contents

    You can try below code. Select range containing the names which you want to convert into the format as you like and then run the macro.
    Please Login or Register  to view this content.
    ❖ Please mark your thread is SOLVED if there has been offered a solution that works fine for you.

    ❖ If you like solutions provided by anyone, feel free to add reputation by clicking on ✶ Add Reputation bottom left of their posts.

  5. #5
    Valued Forum Contributor
    Join Date
    12-22-2015
    Location
    HK
    MS-Off Ver
    2010
    Posts
    532

    Re: Replace cell contents with portion of cell contents

    UDF:
    Please Login or Register  to view this content.
    Attached Files Attached Files

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

    Re: Replace cell contents with portion of cell contents

    Simply
    Please Login or Register  to view this content.

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

    Re: Replace cell contents with portion of cell contents

    An alternative solution is to use Power Query. No coding required. Any names added to your list will automatically be reformatted when the refresh button is selected. Here is the Mcode and a file attached for your review.
    Please Login or Register  to view this content.
    Attached Files Attached Files

+ 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. [SOLVED] Exporting cell contents to PDF - not just the screen-visible portion
    By Orson100 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 07-15-2016, 06:04 PM
  2. Replies: 3
    Last Post: 06-29-2015, 03:03 PM
  3. Find and Replace the contents of one cell with the contents of another
    By thechevs in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-30-2014, 06:48 AM
  4. [SOLVED] Need help writing macro to replace one cell based on contents of adjacent cell
    By TheRaptMuse in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-24-2012, 12:54 PM
  5. Replace portion of data in 1 cell, with all contents of different cell & save as CSV?
    By 1lowbowtie in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 09-17-2011, 11:51 PM
  6. cut a portion of a cell's contents and paste the cut portion into the net column
    By NJEvan in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-12-2010, 05:08 AM
  7. Using MATCH result in Cell Reference to replace cell contents
    By Rolls100 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 02-02-2005, 05:56 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