+ Reply to Thread
Results 1 to 3 of 3

Replacing strings/ replacing numbers and letters

Hybrid View

  1. #1
    Registered User
    Join Date
    07-08-2012
    Location
    NA
    MS-Off Ver
    Excel Starter/Sometimes Excel 2010
    Posts
    33

    Replacing strings/ replacing numbers and letters

    I have a data set that I am trying to edit. I have strings of numbers and characters. I have created an example below.



    Raw data Clean data
    757443V 757443V five RED
    754520V#XY 754520V XY
    267773AFL 267773A FL five RED
    619979 619979 five RED
    MXQAGJ MXQAGJ one blue



    I want to be able to ask excel if some criteria is meet make these changes.


    If there are 6 numbers then a single character then add "five RED" to the end of the cell.
    If there are 6 numbers then a character then a # then two characters substitute x with " ".
    if there are 6 numbers and three characters then put in a space after the first character and add "five RED"
    if just numbers then add "five red"
    if just letters then add "one blue"

    In my data set I have some data that doesn't conform to these rules, that is why I would like a specific code that only edits the data the meets a specific format. My data is quite large so I wont able to make a rule that states replace "AFL" with "A FL five RED". There are many combinations that have 6 numbers then three randomly selected characters. I would not be able to write a line for each unique combination.

    This data is not an exact replication, so I would like to edit my data to fit this data set. I appreciate little explanation.

  2. #2
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    16,040

    Re: Replacing strings/ replacing numbers and letters

    Here, try this:

    Formula: copy to clipboard
    =IF(ISNUMBER(1*LEFT(A1,6)),IF(ISNUMBER(SEARCH("#",LEFT(A1,7)&" "&RIGHT(A1,MAX(0,LEN(A1)-7)))),SUBSTITUTE(LEFT(A1,7)&" "&RIGHT(A1,MAX(0,LEN(A1)-7)),"#",""),LEFT(A1,7)&" "&RIGHT(A1,MAX(0,LEN(A1)-7))&" five RED"),A1&" one blue")
    Never use Merged Cells in Excel

  3. #3
    Registered User
    Join Date
    07-08-2012
    Location
    NA
    MS-Off Ver
    Excel Starter/Sometimes Excel 2010
    Posts
    33

    Re: Replacing strings/ replacing numbers and letters

    Would it be possible to get this in more than one formula? If the formula leaves a blank if the string does not meet the criteria then I can look at it later.
    Then the first formula would look like:
    Raw data Clean data
    757443V 757443V five RED
    754520V#XY "blank"
    267773AFL "blank"
    619979 "blank"
    MXQAGJ "blank"

    Then I could edit each formula to fit my data better.
    Raw data Clean data
    757443V "blank"
    754520V#XY 754520V XY
    267773AFL "blank"
    619979 "blank"
    MXQAGJ "blank"
    Something like this would leave more columns but I can clean that later.
    Help is appreciated!
    Last edited by Insert Name; 05-16-2015 at 01:15 PM. Reason: fix table

+ 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. calculate value based by replacing letters with numbers
    By jbowling in forum Excel Programming / VBA / Macros
    Replies: 23
    Last Post: 06-16-2010, 07:14 PM
  2. Replacing strings within macro's
    By tneva in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 05-05-2009, 08:55 AM
  3. Replacing Text Strings
    By newbie13 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-16-2009, 11:30 AM
  4. Replacing short strings
    By jamieb in forum Excel General
    Replies: 4
    Last Post: 07-28-2008, 09:29 AM
  5. replacing 2 letters in a field
    By manny1975 in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 09-21-2007, 02:15 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