+ Reply to Thread
Results 1 to 5 of 5

Need to replace X in text with A through F

  1. #1
    Registered User
    Join Date
    02-15-2008
    Posts
    4

    Need to replace X in text with A through F

    Good day all,

    I am a Excel VBA rookie (to say the least.) I have a file from an external department that uses "X" as a wildcard to represent the characters A through F in a series of part numbers. I have created some code so that the parts that contain an X is listed 6 times in the original column. Now I want to go through that column that contains those parts (in this case, column B) and, for each X, replace with its appropriate character.

    For example:

    AL4500X03-E6 in rows 9 through 14 in column B becomes:

    AL4500A03-E6
    AL4500B03-E6
    AL4500C03-E6
    AL4500D03-E6
    AL4500E03-E6
    AL4500F03-E6

    And then continue on to the next item that contains an X and replace with A through F in each case again.

    Appreciate any help you can offer!

    Thanks
    Adam

  2. #2
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: Need to replace X in text with A through F

    Can you post a sample workbook? Is the X always the 7th character?

  3. #3
    Registered User
    Join Date
    02-15-2008
    Posts
    4

    Re: Need to replace X in text with A through F

    Sure thing. Yes, X is always the 7th character in the part numbers I'm working with. You will see from the sample, not all the parts in column B will have a wildcard X.
    Attached Files Attached Files

  4. #4
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: Need to replace X in text with A through F

    EDIT: made a right pig's ear of that, will be back shortly so amuse yourself.

    Right, try this. It could be a made a little shorter if your descriptions are common, but I think this works.
    Please Login or Register  to view this content.
    Last edited by StephenR; 11-04-2009 at 01:44 PM.

  5. #5
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Need to replace X in text with A through F

    Hello Adammj58,

    Here is another macro that uses Regular Expressions to find an replace the "X" with the letters you want. A button has been added to the attached workbook to run the macro.
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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