+ Reply to Thread
Results 1 to 3 of 3

sort carerctors in cell

  1. #1
    Forum Contributor
    Join Date
    08-10-2006
    Posts
    723

    sort carerctors in cell

    hi,

    i have data that looks like the following

    1x1234abc
    12x1234abc
    456x1234abc
    1234x1234abc
    1234x1abc
    3456x12abc
    1234x123abc
    1234x1234abc

    i need the data to look like the following

    1234x1223 abc
    1 x1 abc
    12 x12 abc
    in other words the x is always the 5th charector
    the start of the str to be the 11th charector

    spaces must be left from the first number to the x if 4 numbers have not been used. this also applies after the x

    thank you

    steve

  2. #2
    Valued Forum Contributor
    Join Date
    12-16-2004
    Location
    Canada, Quebec
    Posts
    363
    Would this help?
    Sub put_space()
    rowcount = [A:IV].Find("*", [A:IV].Item(1, 1), , , _
    xlByRows, xlPrevious).Row
    For i = 1 To rowcount
    Range("a" & i).Select
    'take current value ie cell a1
    valu = ActiveCell.Value
    'take the last 3 characters ie abc
    const1 = Right(valu, 3)
    'locate the start of a
    valu_pos = InStr(1, valu, "a")
    'take the first part up to a
    vari = Left(valu, valu_pos - 1)
    'adding a space between the 2 value
    new_val = vari & " " & const1
    'replace old value with new_value
    ActiveCell.Value = new_val
    Next
    End Sub

  3. #3
    Forum Contributor
    Join Date
    08-10-2006
    Posts
    723

    sort charectors

    hi,

    this only move the first letter in the string which could be any letter
    i need it ti put space between the number and the x if there is not 4 number before or ater the x

    like 12ssx2ssssabc
    1sssx123ssdcd
    1234x1ssssfgh
    123sx1234styu

    s denotes a space
    the x must be inline IE the 5 charector the first sting lettrs must be the 11th charector

    steve
    Last edited by stevekirk; 09-20-2006 at 04:14 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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