+ Reply to Thread
Results 1 to 11 of 11

TextToColumn or something else will solve this?

  1. #1
    Valued Forum Contributor ImranBhatti's Avatar
    Join Date
    03-27-2014
    Location
    Rawalpindi,Pakistan
    MS-Off Ver
    Office 365
    Posts
    1,784

    TextToColumn or something else will solve this?

    I have some text files with this type of strings

    abc,cde:def;ghi
    jkl.mno>pqr^stu
    vwx,yza:bcd;efg
    hij.klm>nop^qrs


    and so on and so on

    Every two lines has the same pattern and there are at least 100 lines per txt file. Strings has no spaces, no numeric in between only the above six delimeters.
    What I want is to bring every two lines from txt files one by one to the one row of worksheet like show in the snap

    Note: All txt files are named as
    Machine 1
    Machine 2
    Machine 3 and so on
    Attached Images Attached Images
    Teach me Excel VBA

  2. #2
    Forum Guru karedog's Avatar
    Join Date
    10-03-2014
    Location
    Indonesia
    MS-Off Ver
    2003
    Posts
    2,971

    Re: TextToColumn or something else will solve this?

    Maybe :
    Please Login or Register  to view this content.
    Attached Files Attached Files
    1. I care dog
    2. I am a loop maniac
    3. Forum rules link : Click here
    3.33. Don't forget to mark the thread as solved, this is important

  3. #3
    Valued Forum Contributor ImranBhatti's Avatar
    Join Date
    03-27-2014
    Location
    Rawalpindi,Pakistan
    MS-Off Ver
    Office 365
    Posts
    1,784

    Re: TextToColumn or something else will solve this?

    Hi karedog

    Thanks for the effort but I need to wait for Monday as I don't have access to the text files mentioned in the thread. I will let you know about result of your code on Monday.

  4. #4
    Forum Guru karedog's Avatar
    Join Date
    10-03-2014
    Location
    Indonesia
    MS-Off Ver
    2003
    Posts
    2,971

    Re: TextToColumn or something else will solve this?

    Ok, so until Monday then ....

  5. #5
    Valued Forum Contributor ImranBhatti's Avatar
    Join Date
    03-27-2014
    Location
    Rawalpindi,Pakistan
    MS-Off Ver
    Office 365
    Posts
    1,784

    Re: TextToColumn or something else will solve this?

    All right. I overlooked your folder with sample material and solution applied.
    Much appreciated

    It is exactly what I wanted.

    Many thanks indeed

  6. #6
    Valued Forum Contributor ImranBhatti's Avatar
    Join Date
    03-27-2014
    Location
    Rawalpindi,Pakistan
    MS-Off Ver
    Office 365
    Posts
    1,784

    Re: TextToColumn or something else will solve this?

    Another question just for knowledge

    Please Login or Register  to view this content.
    We were taught that only a collection can be looped through like the above. What v is actually (in this example it variant) but is it an object. I mean for each object in Array?

    Or

    Is an array also a collection?

  7. #7
    Forum Guru karedog's Avatar
    Join Date
    10-03-2014
    Location
    Indonesia
    MS-Off Ver
    2003
    Posts
    2,971

    Re: TextToColumn or something else will solve this?

    You are welcome, thanks for marking the thread as solved and rep.points.


    As for :
    Quote Originally Posted by ImranBhatti View Post
    Another question just for knowledge

    We were taught that only a collection can be looped through like the above. What v is actually (in this example it variant) but is it an object. I mean for each object in Array?

    Or

    Is an array also a collection?
    No, who told you that information ?

    Please open the VBA window, highlight the Each word and then press F1 to bring out the help window.

    Microsoft will provide this information on the help :

    Repeats a group of statements for each element in an array or collection.


    So, yes indeed the For Each is also applied for array too.

  8. #8
    Valued Forum Contributor ImranBhatti's Avatar
    Join Date
    03-27-2014
    Location
    Rawalpindi,Pakistan
    MS-Off Ver
    Office 365
    Posts
    1,784

    Re: TextToColumn or something else will solve this?

    Thanks learnt something new. I used to loop through array with For....Next.

  9. #9
    Forum Guru karedog's Avatar
    Join Date
    10-03-2014
    Location
    Indonesia
    MS-Off Ver
    2003
    Posts
    2,971

    Re: TextToColumn or something else will solve this?

    You are welcome.

    Just remember, looping using ForEach for array of simple datatypes (number, date, string, boolean) can only used for read operation only (not write operation), because ForEach will create a copy of data, not the actual data, just as shown below :
    Please Login or Register  to view this content.

  10. #10
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: TextToColumn or something else will solve this?

    Here is a formula solution that may work for you
    Enter formula in B1 and copy across and down
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    v A B C D E F G H I
    1 abc,cde:def;ghi abc cde def ghi jkl mno pqr stu
    2 jkl.mno>pqr^stu vwx yza bcd efg hij klm nop qrs
    3 vwx,yza:bcd;efg rrr bbb sss ggg opp nno lnb pkk
    4 hij.klm>nop^qrs
    5 rrr.bbb.sss;ggg
    6 opp.nno,lnb,pkk
    If you like my answer please click on * Add Reputation
    Don't forget to mark threads as "Solved" if your problem has been resolved

    "Nothing is so firmly believed as what we least know."
    --Michel de Montaigne

  11. #11
    Valued Forum Contributor ImranBhatti's Avatar
    Join Date
    03-27-2014
    Location
    Rawalpindi,Pakistan
    MS-Off Ver
    Office 365
    Posts
    1,784

    Re: TextToColumn or something else will solve this?

    @sir Alkey

    Appreciated the formula. I have kept it if I plan to avoid a VBA code in future.

    But currently I have large number of txt files and the vba solution is applied as it will also copy the data from txt files. Many thanks indeed.

+ 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. [SOLVED] Solve for X?
    By mitch22 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 09-17-2014, 12:17 PM
  2. How to do texttoColumn delimited by space in column?
    By lee478 in forum Excel General
    Replies: 4
    Last Post: 12-15-2013, 06:50 PM
  3. Strange Texttocolumn behaviour
    By Mbrolass in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-29-2008, 01:17 PM
  4. i need to solve this please!
    By freakzilla in forum Excel General
    Replies: 3
    Last Post: 10-26-2006, 09:10 AM
  5. y i cannot solve it ?
    By cjjoo in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 09-26-2005, 07:05 AM
  6. [SOLVED] TextToColumn Split
    By Stitch45 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-14-2005, 12:05 PM
  7. [SOLVED] How to solve?
    By Lee Tow in forum Excel General
    Replies: 2
    Last Post: 06-24-2005, 08:05 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