+ Reply to Thread
Results 1 to 7 of 7

Need macro to insert modified cell text between other cells

  1. #1
    Registered User
    Join Date
    07-05-2019
    Location
    Canada
    MS-Off Ver
    2019
    Posts
    4

    Need macro to insert modified cell text between other cells

    Hi everyone,

    I need help with the following:

    I have a list of 150 names in a single spreadsheet row, and I want to insert 4 modified versions of each name between each unique name for the whole row.

    So let's say for example we have:

    Andrew, Bill, Courtney in a row.

    I want to end up with:

    Andrew Black, Andrew Red, Andrew Blue, Andrew Green, Bill Black, Bill Red, Bill Blue, Bill Green, Courtney Black, Courtney Red, Courtney Blue, Courtney Green, and so on.

    Can someone help me with a macro to automate this, as doing this manually for 150 cells will be quite tedious.

    Thanks in advance

  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,887

    Re: Need macro to insert modified cell text between other cells

    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
    07-05-2019
    Location
    Canada
    MS-Off Ver
    2019
    Posts
    4

    Re: Need macro to insert modified cell text between other cells

    Sample sheets are attached. Thanks again for the help.
    Attached Files Attached Files

  4. #4
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Cool Hi ! Try this ‼


    According to your attachment as a beginner starter :

    PHP Code: 
    Sub Demo()
        
    Dim VWS$(), XYC%
            
    = [A1].CurrentRegion.Rows(1).Value2
            W 
    = [{" Black"," Red"," Blue"," Green"}]
            
    ReDim S(1 To UBound(V2) * UBound(W))
        For 
    Each X In V
            
    For Each Y In W
                C 
    1
                S
    (C) = Y
            Next
        Next
        With 
    [A1].Resize(, UBound(S))
            .
    Value2 S
            
    .Columns.AutoFit
        End With
    End Sub 
    Do you like it ? So thanks to click on bottom left star icon « Add Reputation » !
    Last edited by Marc L; 07-05-2019 at 10:11 PM. Reason: optimisation …

  5. #5
    Registered User
    Join Date
    07-05-2019
    Location
    Canada
    MS-Off Ver
    2019
    Posts
    4

    Re: Need macro to insert modified cell text between other cells

    This is perfect. Thank you so much. Rep added.

  6. #6
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,869

    Re: Need macro to insert modified cell text between other cells

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED. Thanks.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  7. #7
    Registered User
    Join Date
    07-05-2019
    Location
    Canada
    MS-Off Ver
    2019
    Posts
    4

    Re: Need macro to insert modified cell text between other cells

    Done. Thanks.
    Last edited by AliGW; 07-05-2019 at 10:35 PM. Reason: Please don't quote unnecessarily!

+ 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. Vba that moves cells with text, (up and to left, insert row/ insert copied cell)
    By sergi117 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-04-2018, 03:12 PM
  2. Macro that will insert a simple text string in top cell of text file
    By Davek11 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-25-2014, 07:31 PM
  3. Formula to identify part of a text in cell from range of cells & insert adjacent cell text
    By Novicebutnotforlong in forum Excel Formulas & Functions
    Replies: 11
    Last Post: 11-19-2013, 02:11 AM
  4. Replies: 2
    Last Post: 11-07-2013, 06:19 AM
  5. Replies: 1
    Last Post: 08-04-2011, 03:45 PM
  6. Replies: 2
    Last Post: 08-03-2011, 12:40 PM
  7. Replies: 0
    Last Post: 03-23-2006, 05:45 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