+ Reply to Thread
Results 1 to 9 of 9

Adding text to a cell based on specific text characters in another cell

  1. #1
    Forum Contributor
    Join Date
    04-25-2011
    Location
    Donegal, Ireland
    MS-Off Ver
    Excel 2013
    Posts
    133

    Adding text to a cell based on specific text characters in another cell

    Hi, I receive a daily list of around 4k-5k products that up until now is taking me hours to sort.

    Attached is a tiny sample of my dilemna. There are 4 columns A and D and 7 rows 2-8.

    From the text in range A2:A8 I need to recognise and remove the 'R' at the end of the text in rows 2,4,5,6 - The '-Demo' in row 3,
    the '-R' in row 7 and the 'WR' in row 8. and insert the results in the corresponding cells in Column B as shown on the worksheet.

    Then i need to have specific text inserted in Column D based on the last 2 characters from the cells in Column C.

    The 'C' column range is all 6 digit numbers with 2 letters on the end. These are either 'R4' or 'N1'.

    R4 = Refurbished
    N1 = New

    I have several macros that run within the sheet but I cannot figure this one out, any help would be fantastic

    Regards
    John
    Attached Files Attached Files

  2. #2
    Forum Contributor
    Join Date
    12-31-2012
    Location
    Jhang, Pakistan
    MS-Off Ver
    Excel 2010
    Posts
    250

    Re: Adding text to a cell based on specific text characters in another cell

    Can be there other letters to be removed rather than R, -Demo, -R and WR??

  3. #3
    Forum Expert
    Join Date
    08-28-2014
    Location
    Texas, USA
    MS-Off Ver
    2016
    Posts
    1,796

    Re: Adding text to a cell based on specific text characters in another cell

    Please Login or Register  to view this content.
    Edit: it ran for me on 4000 records in about 1/3 of a second, so hopefully that saves you some time
    Last edited by walruseggman; 10-29-2014 at 04:43 PM.

  4. #4
    Forum Contributor
    Join Date
    04-25-2011
    Location
    Donegal, Ireland
    MS-Off Ver
    Excel 2013
    Posts
    133

    Re: Adding text to a cell based on specific text characters in another cell

    Hi hafizimran, There are other letters to be removed but I figured if I got pointed in the right direction I'd be able to add these later.

    Really appreciate the superfast response and your time.

    I'll try your solution on the big sheet and let you know how i get on.

    Something I forgot to mention is that the columns on the main sheet will be different, will this still work ok?

    Many thanks
    Johnny
    Last edited by JohnnyBoyxxx; 10-29-2014 at 05:05 PM.

  5. #5
    Forum Expert
    Join Date
    08-28-2014
    Location
    Texas, USA
    MS-Off Ver
    2016
    Posts
    1,796

    Re: Adding text to a cell based on specific text characters in another cell

    Hi Johnny, it was my code, not hafizimran's, but it doesn't matter.

    What do you mean the columns will be "different"? If you just mean they won't be in columns A and C, it's a simple matter of changing the check range and possibly the offsets.

  6. #6
    Forum Contributor
    Join Date
    04-25-2011
    Location
    Donegal, Ireland
    MS-Off Ver
    Excel 2013
    Posts
    133

    Re: Adding text to a cell based on specific text characters in another cell

    Hi walruseggman,

    So sorry, I didn't look properly.

    Just ran it and it's so fast, amazing, Just one little hurdle.

    In the sample sheet the source columns are A and C and the results are shown in B and D columns, is it possible to amend this to A and B and J and K columns respectively.

    And I apologise again for the mistaken credit

    UPDATE: I managed to amend your code to suit and it works perfectly, this effort you made on my behalf will save me hours of boring, daily, repetitive work.

    Many Thanks
    Johnny
    Last edited by JohnnyBoyxxx; 10-29-2014 at 05:56 PM.

  7. #7
    Forum Expert
    Join Date
    08-28-2014
    Location
    Texas, USA
    MS-Off Ver
    2016
    Posts
    1,796

    Re: Adding text to a cell based on specific text characters in another cell

    Oh it wasn't about the credit, I just didn't want you to be confused like "why is one user responding to another user's code?" Anyway:

    So the Offsets determine the columns. Offsets are, just in this case, columns to the right of A. So an offset of (0,1) would be 1 column to the right (and zero rows up or down), i.e. column B of the same row. So it's a simple mod, you can see the offset changes. Hopefully this explanation will help if you ever need to adjust the columns.

    Please Login or Register  to view this content.

  8. #8
    Forum Contributor
    Join Date
    04-25-2011
    Location
    Donegal, Ireland
    MS-Off Ver
    Excel 2013
    Posts
    133

    Re: Adding text to a cell based on specific text characters in another cell

    Yeah, i got it after studying what you'd done. Added a Reputation remark, great work and many many thanks, you've made my evening.

  9. #9
    Forum Expert
    Join Date
    08-28-2014
    Location
    Texas, USA
    MS-Off Ver
    2016
    Posts
    1,796

    Re: Adding text to a cell based on specific text characters in another cell

    Glad to help. Always nice to help someone save a bunch of time.

+ 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. Remove Specific Characters From Text Cell
    By chasfh in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 03-18-2014, 10:38 AM
  2. Adding text in a cell based on the contents of the cell above
    By trep420 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-01-2013, 07:06 PM
  3. [SOLVED] Help to return only first 12 characters when a cell contains specific text
    By ports83 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-25-2012, 10:30 PM
  4. [SOLVED] Displaying Specific Text in Cell Based on Text in Another
    By wowcrofty in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 07-29-2012, 12:11 PM
  5. Replies: 1
    Last Post: 05-20-2005, 01:07 AM

Tags for this Thread

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