+ Reply to Thread
Results 1 to 18 of 18

VB Code to split data

  1. #1
    Registered User
    Join Date
    06-07-2013
    Location
    South Africa
    MS-Off Ver
    Excel 2010
    Posts
    19

    VB Code to split data

    HI All

    I hoping someone can help me with this.

    I have data only in Column A, its Alphanumeric and numeric numbers.

    Example of Data
    992G73
    992G83
    992H11
    992H86
    992I18
    992I24
    992I41
    992I47
    993D81
    993I86
    995E15


    What I need is this data to be split like this.

    992|G|73
    992|G|83
    992|H|11
    992|H|86
    992|I|18
    992|I|24
    992|I|41
    992|I|47
    993|D|81
    993|I|86
    995|E|15

    Can anyone help me?

  2. #2
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: VB Code to split data

    Is the input data always 3 numbers, one letter two numbers? If so use this formula:
    =left(A1,3)&"|"&mid(A1,4,1)&"|"&right(A1,2)

    note, you can do the same thing in vba:
    Please Login or Register  to view this content.

  3. #3
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: VB Code to split data

    Is the pattern always 3 digits, one letter, two digits? If yes, you could use the Text-to-Columns feature; fixed width option.

    EDIT: I interpreted the bars to be cells. Split the data into three columns. Is that what you want?
    Last edited by AlphaFrog; 11-27-2013 at 06:38 AM.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  4. #4
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: VB Code to split data

    Or:

    Please Login or Register  to view this content.
    Regards
    Click * below if this answer helped

    Advanced Excel Techniques: http://excelxor.com/

  5. #5
    Registered User
    Join Date
    06-07-2013
    Location
    South Africa
    MS-Off Ver
    Excel 2010
    Posts
    19

    Re: VB Code to split data

    Hi

    Thank you for the response.

    No, there could be.

    4434B52
    1000C52

  6. #6
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: VB Code to split data

    "Is the pattern always 3 digits, one letter, two digits?"

    "No, there could be.

    4434B52
    1000C52
    "

    Then why on earth have you given 11 examples, all of which are of that format?

    Regards

  7. #7
    Registered User
    Join Date
    06-07-2013
    Location
    South Africa
    MS-Off Ver
    Excel 2010
    Posts
    19

    Re: VB Code to split data

    Hi XOR LX

    My apologies, In my rush, I just copied the data and pasted it in, without look at the bigger picture. I looked at all the data the only number of digits that change is the first string, then its always one Alpha and then 2 digits.

  8. #8
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: VB Code to split data

    Using formulas.

    Formula: copy to clipboard
    Please Login or Register  to view this content.



    Formula: copy to clipboard
    Please Login or Register  to view this content.


    The second one is an Array formula.

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    You can record these as macro if you like.

    -- Array(CSE) { }, formulae are confirmed with Control+Shift+Enter.
    Not just Enter.
    Regards

    Fotis.

    -This is my Greek whisper to Europe.

    --Remember, saying thanks only takes a second or two. Click the little star * below, to give some Rep if you think an answer deserves it.

    Advanced Excel Techniques: http://excelxor.com/

    --KISS(Keep it simple Stupid)

    --Bring them back.

    ---See about Acropolis of Athens.

    --Visit Greece.

  9. #9
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: VB Code to split data

    Maybe you need some additional examples covering the possibilities, if those are the only two variations then you could use:
    =left(A1,if(len(A1=6),3,4))&"|"&mid(A1,=if(len(A1=6),4,5),1)&"|"&right(A1,2)

  10. #10
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,516

    Re: VB Code to split data

    VBA
    Please Login or Register  to view this content.

  11. #11
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: VB Code to split data

    Or this, perhaps:

    Please Login or Register  to view this content.
    Regards
    Last edited by XOR LX; 11-27-2013 at 07:05 AM.

  12. #12
    Registered User
    Join Date
    06-07-2013
    Location
    South Africa
    MS-Off Ver
    Excel 2010
    Posts
    19

    Re: VB Code to split data

    HI Fotis1991

    these formula does not seem to work, properly please see below results

    004E22 400 #VALUE! 22
    004E24 400 #VALUE! 24
    004E25 400 #VALUE! 25
    004E26 400 #VALUE! 26
    004E28 400 #VALUE! 28
    004E31 4000 #VALUE! 31
    004E33 4000 #VALUE! 33
    004E34 4000 #VALUE! 34
    004E37 4000 #VALUE! 37
    004E38 4000 #VALUE! 38
    004E42 40000 #VALUE! 42
    004E46 40000 #VALUE! 46
    004E48 40000 #VALUE! 48
    004E51 400000 #VALUE! 51
    004E52 400000 #VALUE! 52

  13. #13
    Registered User
    Join Date
    06-07-2013
    Location
    South Africa
    MS-Off Ver
    Excel 2010
    Posts
    19

    Re: VB Code to split data

    HI jindon and XOR LX

    I'm very new at this, and I do apologize for my ignorance on the matter. its working great, exactly as I explained in the illustration, but I meant with the pipe sign to represent a new column.

    A B C
    992|G|73
    992|G|83

  14. #14
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: VB Code to split data

    you could add something like:
    Please Login or Register  to view this content.
    to the end of either XOR LX or jindon's code.

  15. #15
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,516

    Re: VB Code to split data

    Quote Originally Posted by Oszie View Post
    HI jindon and XOR LX

    I'm very new at this, and I do apologize for my ignorance on the matter. its working great, exactly as I explained in the illustration, but I meant with the pipe sign to represent a new column.

    A B C
    992|G|73
    992|G|83
    Change to
    Please Login or Register  to view this content.

  16. #16
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: VB Code to split data

    Argghh!!!

    Only kidding! No worries:

    Please Login or Register  to view this content.
    Regards

  17. #17
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: VB Code to split data

    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Attached Files Attached Files

  18. #18
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,516

    Re: VB Code to split data

    Oszie
    Thanks for the rep and if the problem is solved, please mark the thread as "SOLVED".

    OOps, just marked so...

+ 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. need vba code to split 3 column data as name of workbook into target folder
    By breadwinner in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-17-2013, 05:29 AM
  2. change merge code to split the data
    By bujji1305 in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 05-23-2012, 02:28 AM
  3. how to convert excel split code to word split code
    By gsrikanth in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-02-2012, 07:56 AM
  4. Mod code to split text
    By karinos57 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-25-2007, 10:27 PM
  5. Split code in more than one page ?
    By SpookiePower in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-16-2006, 06:25 AM

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