+ Reply to Thread
Results 1 to 18 of 18

Import text file into excel and split data in specific sheets

  1. #1
    Registered User
    Join Date
    06-12-2012
    Location
    bucharest
    MS-Off Ver
    Excel 2010
    Posts
    20

    Import text file into excel and split data in specific sheets

    Hello,
    I attached my .txt data file named "data". I also attach the excel file, to help you to understand what i really need.
    I need a VBA solution for import the informations in excel.
    The challenge is to split this data into multiple sheets, by "Node Name".

    for example:
    in sheet 1, will be imported data from node name 17GHEB, the sheet name will become 17GHEB.
    so on

    best regards, i hope somebody can help me
    Attached Files Attached Files

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

    Re: Import text file into excel and split data in specific sheets

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    06-12-2012
    Location
    bucharest
    MS-Off Ver
    Excel 2010
    Posts
    20

    Re: Import text file into excel and split data in specific sheets

    Thanks yudlugar! that code works really fine. but that informations are copied into one column.
    I need to get that data in separate columns. In fact, i need to get only day, volume and energy. can be done?
    Anyway, i appreciate your effort, you are really good!
    Best regards,
    Ionut

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

    Re: Import text file into excel and split data in specific sheets

    Try this
    Please Login or Register  to view this content.

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

    Re: Import text file into excel and split data in specific sheets

    I came up with this:
    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    06-12-2012
    Location
    bucharest
    MS-Off Ver
    Excel 2010
    Posts
    20

    Re: Import text file into excel and split data in specific sheets

    yudlugar, that works amazing!! thanks! you are the best! have a nice day!
    Last edited by chirilaionut; 05-30-2013 at 06:57 AM.

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

    Re: Import text file into excel and split data in specific sheets

    Did you change the filepath?

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

    Re: Import text file into excel and split data in specific sheets

    Place both Excel and text file in the same folder and try again.

    It is working here.
    Attached Files Attached Files

  9. #9
    Registered User
    Join Date
    06-12-2012
    Location
    bucharest
    MS-Off Ver
    Excel 2010
    Posts
    20

    Re: Import text file into excel and split data in specific sheets

    wow!
    Thank you both! you are really amazing!
    both answers works just fine!!
    thank you again!
    Last edited by chirilaionut; 05-30-2013 at 07:01 AM.

  10. #10
    Registered User
    Join Date
    06-12-2012
    Location
    bucharest
    MS-Off Ver
    Excel 2010
    Posts
    20

    Re: Import text file into excel and split data in specific sheets

    a stupid question: if i want to import other column (for example: "pressure" from that .txt file, what should i change into the jindon's code?
    i looked at the code 1 hour today and i still feel stupid...
    thanks again, you are doing a great job!

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

    Re: Import text file into excel and split data in specific sheets

    Try this
    Please Login or Register  to view this content.
    Last edited by jindon; 05-31-2013 at 08:50 AM.

  12. #12
    Registered User
    Join Date
    06-12-2012
    Location
    bucharest
    MS-Off Ver
    Excel 2010
    Posts
    20

    Re: Import text file into excel and split data in specific sheets

    thanks man! you rulllzzzzzzz!

  13. #13
    Registered User
    Join Date
    06-12-2012
    Location
    bucharest
    MS-Off Ver
    Excel 2010
    Posts
    20

    Re: Import text file into excel and split data in specific sheets

    jindon, help me please! from "energy" are imported only last number before dot and decimales. (ex from 1234.44 are imported 4.44)
    Last edited by chirilaionut; 06-03-2013 at 03:04 AM.

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

    Re: Import text file into excel and split data in specific sheets

    Can you just add one space after 3 rd asterisk?
    Please Login or Register  to view this content.

  15. #15
    Registered User
    Join Date
    06-12-2012
    Location
    bucharest
    MS-Off Ver
    Excel 2010
    Posts
    20

    Re: Import text file into excel and split data in specific sheets

    Thx, u r big in japan!
    have a nice day!

  16. #16
    Registered User
    Join Date
    06-12-2012
    Location
    bucharest
    MS-Off Ver
    Excel 2010
    Posts
    20

    Re: Import text file into excel and split data in specific sheets

    jindon, could you explain the logic of this code?
    i understand it about 90%, but something it's not very clear to me. for instance, i try to extend that code for 6 columns:

    Sheets(t).Cells(n, 1).Resize(, 6).Value = _
    [{"day","Flow hrs.","presure","diff","Energy kWh","Volume m3"}]
    End If
    If n > 0 Then
    .Pattern = "^ *(\d+) *(\d+\.\d{2}).\D+ *(\d+\.\d{2})*(\d+\.\d{2}).\D+ +(\d+\.\d{2}).* (\d+\.\d{2}) *(\d+\.\d{2})*(\d+\.\d{2}) *$"

    but, it appear a blank on "pressure" column. what i did wrong?
    it seems that i am not smart enough...

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

    Re: Import text file into excel and split data in specific sheets

    Please Login or Register  to view this content.

  18. #18
    Registered User
    Join Date
    06-12-2012
    Location
    bucharest
    MS-Off Ver
    Excel 2010
    Posts
    20

    Re: Import text file into excel and split data in specific sheets

    finally i get it!! i understand the meaning of code! you are great man, i really apreciate your work! thanks very much again, best regards!

+ 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