+ Reply to Thread
Results 1 to 11 of 11

Adding a suffix to one cell if there is specific text in another cell in the same row

  1. #1
    Registered User
    Join Date
    04-11-2017
    Location
    Vancouver, BC
    MS-Off Ver
    Office 365
    Posts
    6

    Adding a suffix to one cell if there is specific text in another cell in the same row

    Hi Everyone,

    Long time reader and I have finally signed up to this lovely forum, so hello

    I have been googling for quite sometime on this request.

    Column 1 (Data example):
    001-MUY-000-002-003-MBA-ABC
    001-000-000-345-003-MBA-ABC

    Column 2
    QC
    TBAY

    So basically I want to do the following: Looking at each row separately, if Column 2 has specific text "QC" to put a suffix "_FR" in column 1. Same goes for specific text "TBAY" to put a suffix "_EN".
    So the result being:
    001-MUY-000-002-003-MBA-ABC_FR
    001-000-000-345-003-MBA-ABC_EN

    Is this even possible? if anyone can help me would be greatly appreciated.

  2. #2
    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: Adding a suffix to one cell if there is specific text in another cell in the same row

    In column C, =IF(B1="QC",CONCATENATE(A1,"_","FR"),IF(B1="TBAY",CONCATENATE(A1,"_","EN"),A1))
    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
    04-11-2017
    Location
    Vancouver, BC
    MS-Off Ver
    Office 365
    Posts
    6

    Re: Adding a suffix to one cell if there is specific text in another cell in the same row

    Ah thanks for that!

    Is there anyway it can just format column A?

  4. #4
    Forum Expert
    Join Date
    06-09-2010
    Location
    Australia
    MS-Off Ver
    Excel 2013
    Posts
    1,714

    Re: Adding a suffix to one cell if there is specific text in another cell in the same row

    Hi
    there are at least two ways to do this
    using a formula in a new column to combine something like this
    =IF(B1="QC",A1&"_FR",IF(B1="TBAY",A1&"_EN",A1))


    or a macro which will permanently overwrite the contents of the original cell, like this:
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    04-11-2017
    Location
    Vancouver, BC
    MS-Off Ver
    Office 365
    Posts
    6

    Re: Adding a suffix to one cell if there is specific text in another cell in the same row

    The Macro is perfect thank you!!

  6. #6
    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: Adding a suffix to one cell if there is specific text in another cell in the same row

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

  7. #7
    Registered User
    Join Date
    04-11-2017
    Location
    Vancouver, BC
    MS-Off Ver
    Office 365
    Posts
    6

    Re: Adding a suffix to one cell if there is specific text in another cell in the same row

    Hi I was just wondering if there are other specific text that pop up I can just add the line in the below in red and it will work???

    Please Login or Register  to view this content.
    Last edited by alansidman; 04-12-2017 at 03:27 PM.

  8. #8
    Registered User
    Join Date
    04-11-2017
    Location
    Vancouver, BC
    MS-Off Ver
    Office 365
    Posts
    6

    Re: Adding a suffix to one cell if there is specific text in another cell in the same row

    Also, can I change the range as I am working with a big spreadsheet eg: "C2:C630", assuming this in the column 1?

  9. #9
    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: Adding a suffix to one cell if there is specific text in another cell in the same row

    L_A_C
    Code Tags Added
    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found at http://www.excelforum.com/forum-rule...rum-rules.html



    (I have added them for you today. Please take a few minutes to read all Forum Rules and comply in the future.)

  10. #10
    Registered User
    Join Date
    04-11-2017
    Location
    Vancouver, BC
    MS-Off Ver
    Office 365
    Posts
    6

    Re: Adding a suffix to one cell if there is specific text in another cell in the same row

    Sorry about that!

  11. #11
    Forum Expert
    Join Date
    06-09-2010
    Location
    Australia
    MS-Off Ver
    Excel 2013
    Posts
    1,714

    Re: Adding a suffix to one cell if there is specific text in another cell in the same row

    yes, if you stick to that code structure you should be able to add as many variations as you like; and if you replace A1:A10 with the range to change in MyRange then it will work over whatever range you specify.

    If you have a large number of different suffixes it may be simpler to create a couple of arrays rather than coding each one separately. let me know if you'd like to do it this way

+ 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. Adding a random prefix and suffix to a cell
    By alexadept in forum Excel General
    Replies: 1
    Last Post: 04-02-2015, 07:42 PM
  2. [SOLVED] Adding text to a cell based on specific text characters in another cell
    By JohnnyBoyxxx in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 10-29-2014, 06:03 PM
  3. [SOLVED] Adding Suffix to a cell value
    By AliiShariff in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-27-2012, 09:04 AM
  4. Adding a code/ suffix to text
    By jamiek in forum Excel General
    Replies: 1
    Last Post: 05-25-2011, 12:40 PM
  5. Adding a suffix to a cell
    By darren1908 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 11-25-2008, 10:23 AM
  6. auto-adding specific suffix to user value?
    By ncd10482 in forum Excel General
    Replies: 4
    Last Post: 07-08-2008, 08:03 AM
  7. adding a string prefix/suffix to a cell
    By elroy in forum Excel General
    Replies: 4
    Last Post: 03-08-2007, 04:47 AM

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