+ Reply to Thread
Results 1 to 6 of 6

Separate text numbers and characters into coulmns

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    11-28-2005
    Location
    Dover, England
    MS-Off Ver
    365
    Posts
    172

    Separate text numbers and characters into coulmns

    I have the following type data given below and I need to separate each of the groups whether it be text, numeric or character into individual columns .

    The data is:
    ACC30X30X6
    30X30X6ACS
    ACS30X6
    BSC25*25*8
    25*40*8DDF

    and as an example I would like it to be: acc | 30 | x | 30 | x | 6

    Does anyone have an idea as to how this could be achieved whether by formula or coding?

    Thanks
    Last edited by Tellm; 02-24-2012 at 04:58 AM.

  2. #2
    Forum Expert
    Join Date
    03-23-2004
    Location
    London, England
    MS-Off Ver
    Excel 2019
    Posts
    7,080

    Re: Separate text numbers and characters into coulmns

    What about the other lines as some of them don't conform to the same format, e.g. line 3 ACS30X6, how should that be split?
    Regards
    Special-K

    Ensure you describe your problem clearly, I have little time available to solve these problems and do not appreciate numerous changes to them.

  3. #3
    Forum Contributor
    Join Date
    11-28-2005
    Location
    Dover, England
    MS-Off Ver
    365
    Posts
    172

    Re: Separate text numbers and characters into coulmns

    Special-K - just the same: ACS | 30 | X | 6

    Thanks

  4. #4
    Valued Forum Contributor
    Join Date
    10-15-2007
    Location
    Home
    MS-Off Ver
    Office 2010, W10
    Posts
    373

    Re: Separate text numbers and characters into coulmns

    Hi Tellm

    With the strings in A1, down, try:

    Sub SplitString()
    Dim r As Range, rC As Range
    Dim vArr As Variant
    
    Set r = Range("A1", Range("A1").End(xlDown))
    With CreateObject("VBScript.RegExp")
        .Pattern = "(\d+|[a-zA-Z]+|[^0-9a-zA-Z]+)"
        .Global = True
        For Each rC In r
            If rC.Text <> "" Then
                vArr = Split(Mid(.Replace(rC.Text, Chr(1) & "$1"), 2), Chr(1))
                rC.Offset(, 1).Resize(1, UBound(vArr) + 1) = vArr
            End If
        Next rC
    End With
    End Sub
    The code splits the text displayed in the cells and writes the result in the cells to the right.

  5. #5
    Forum Contributor
    Join Date
    11-28-2005
    Location
    Dover, England
    MS-Off Ver
    365
    Posts
    172

    Re: Separate text numbers and characters into coulmns

    Lecxe - this is perfect, many many thanks.

  6. #6
    Valued Forum Contributor
    Join Date
    10-15-2007
    Location
    Home
    MS-Off Ver
    Office 2010, W10
    Posts
    373

    Re: Separate text numbers and characters into coulmns

    You're welcome. Thanks for the feedback.

+ 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