+ Reply to Thread
Results 1 to 26 of 26

Import text file that contains rows into excel as columns

  1. #1
    Registered User
    Join Date
    03-13-2017
    Location
    US
    MS-Off Ver
    2016
    Posts
    13

    Import text file that contains rows into excel as columns

    I have a text file with a bunch of data in the following format. I want to get into excel where ID, Submission Date, WebName ,etc would all be column headers and the corresponding date after : would be the data under the appropriate column. I've tried transpose. I've tried using delimited (some say hit alt + 0010 or something for other (computer just beeps as I'm trying to enter that). I'm not a programmer by any means. Any suggestions are appreciated.

    Row 2:
    ID: (392962)
    Submission Date: 3/20/2015 11:12 AM
    WebName: "mysite.co.com"
    Requester: "admin"
    Expiration Date: 3/19/2017 11:02 AM

    Row 3:
    ID: (392995)
    Submission Date: 4/20/2015 11:12 AM
    WebName: "url.co.com"
    Requester: "admin2"
    Expiration Date: 4/19/2017 11:02 AM

  2. #2
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,551

    Re: Import text file that contains rows into excel as columns

    Can you upload an example of your text file?
    Thanks,
    Mike

    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved.

  3. #3
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    6,351

    Re: Import text file that contains rows into excel as columns

    This assumes that the lines are split by tabs - your one row is shown on 5 rows, and what comes between the entries actually matters, so you may need to post an example file.

    Anyway, try code like this

    Please Login or Register  to view this content.
    Bernie Deitrick
    Excel MVP 2000-2010

  4. #4
    Registered User
    Join Date
    03-13-2017
    Location
    US
    MS-Off Ver
    2016
    Posts
    13

    Re: Import text file that contains rows into excel as columns

    Seems like the javascript to attach isn't working from multiple browsers. The format you see is it. Just save as a text file. If it was comma or tab, I'd be all set. Not that simple. Entries are on different lines. Thanks

    Row 1:
    ID: 0x5ee83 (388739)
    Submission Date: 3/13/2015 11:38 AM
    WebName: "mysite.co.com"
    Name: "admin"
    Expiration Date: 3/12/2017 11:28 AM

    Row 2:
    ID: 0x5ff02 (392962)
    Submission Date: 3/20/2015 11:12 AM
    WebName: "url.co.com"
    Requester: "admin2"
    Expiration Date: 3/19/2017 11:02 AM

    Row 3:
    ID: 0x60bba (396218)
    Submission Date: 3/25/2015 2:19 PM
    WebName: "mainpage.co.com"
    Requester: "admin3"
    Expiration Date: 3/24/2017 2:09 PM
    Last edited by cbiz; 03-13-2017 at 01:19 PM.

  5. #5
    Registered User
    Join Date
    03-13-2017
    Location
    US
    MS-Off Ver
    2016
    Posts
    13

    Re: Import text file that contains rows into excel as columns

    @Bernie...ran the code you gave against the 3 rows above and output is just the first row section

    0x5ee83 (388739)
    3/13/2015 11
    "mysite.co.com"
    "admin"
    3/12/2017 11

    All in the same column. Whereas my wish is column A 0x5ee83 (388739), B 3/13/2015 11 (notice using : as the delimiter check gets tripped up by the time value)...even more complicated I don't care about the time really, but I do care about the date

  6. #6
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    6,351

    Re: Import text file that contains rows into excel as columns

    Try it this way - slightly editied so don't use the version in your email if you got a notice:

    Please Login or Register  to view this content.
    Last edited by Bernie Deitrick; 03-13-2017 at 01:21 PM.

  7. #7
    Registered User
    Join Date
    03-13-2017
    Location
    US
    MS-Off Ver
    2016
    Posts
    13

    Re: Import text file that contains rows into excel as columns

    0x5ee83 (388739) 3/13/2015 11:38 "mysite.co.com" "admin"
    3/12/2017 11:28 0x5ff02 (392962) 3/20/2015 11:12
    "url.co.com" "admin2" 3/19/2017 11:02
    0x60bba (396218) 3/25/2015 14:19 "mainpage.co.com" "admin3" 3/24/2017 14:09 different columns now but can't figure out why it chose the columns it did

  8. #8
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,551

    Re: Import text file that contains rows into excel as columns

    Why is row Name: and rows 2 & 3 are Requester:

    Row 1:
    ID: 0x5ee83 (388739)
    Submission Date: 3/13/2015 11:38 AM
    WebName: "mysite.co.com"
    Name: "admin"
    Expiration Date: 3/12/2017 11:28 AM

    Row 2:
    ID: 0x5ff02 (392962)
    Submission Date: 3/20/2015 11:12 AM
    WebName: "url.co.com"
    Requester: "admin2"
    Expiration Date: 3/19/2017 11:02 AM

    Row 3:
    ID: 0x60bba (396218)
    Submission Date: 3/25/2015 2:19 PM
    WebName: "mainpage.co.com"
    Requester: "admin3"
    Certificate Expiration Date: 3/24/2017 2:09 PM

  9. #9
    Registered User
    Join Date
    03-13-2017
    Location
    US
    MS-Off Ver
    2016
    Posts
    13

    Re: Import text file that contains rows into excel as columns

    sorry those should all be requester. Trying to mask the real data before I send. That last one has Certificate too. Again it should match others. (Expiration Date)
    Last edited by cbiz; 03-13-2017 at 02:45 PM.

  10. #10
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    6,351

    Re: Import text file that contains rows into excel as columns

    Try this - put your labels into row 1 of the active sheet (up to but without the : ID, Submission Date, WebNam, Requester, Expiration Date) and run this:

    Please Login or Register  to view this content.
    Last edited by Bernie Deitrick; 03-13-2017 at 03:21 PM.

  11. #11
    Registered User
    Join Date
    03-13-2017
    Location
    US
    MS-Off Ver
    2016
    Posts
    13

    Re: Import text file that contains rows into excel as columns

    unfortunately I didn't get output in excel this time. No errors

  12. #12
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    6,351

    Re: Import text file that contains rows into excel as columns

    Probably your row 1 values - this should flag missing headers:

    Please Login or Register  to view this content.

  13. #13
    Registered User
    Join Date
    03-13-2017
    Location
    US
    MS-Off Ver
    2016
    Posts
    13

    Re: Import text file that contains rows into excel as columns

    tried to upload sample to make sure it's not something silly. Not sure if manage attachment worked

  14. #14
    Registered User
    Join Date
    03-13-2017
    Location
    US
    MS-Off Ver
    2016
    Posts
    13

    Re: Import text file that contains rows into excel as columns

    could not find this in row 1: "Row 2"

    A1 is ID, B1 is Submission Date, C1 is WebName, D1 is Requester, E1 Expiration Date I bet it's complaining because the : after the Row #

  15. #15
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Import text file that contains rows into excel as columns

    Hello cbiz,

    This macro has been tested on the data you provided in post #4. The text is placed in the correct columns "A:E" starting with row 2. Any

    previous data is cleared when the macro runs.

    The attached workbook has the macro added and button to run it. It will allow you to select the file to open (text only). Here is the

    macro code...

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  16. #16
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    6,351

    Re: Import text file that contains rows into excel as columns

    oops - I thought the Row labels were things that you added, so try this one:

    Please Login or Register  to view this content.

  17. #17
    Registered User
    Join Date
    03-13-2017
    Location
    US
    MS-Off Ver
    2016
    Posts
    13

    Re: Import text file that contains rows into excel as columns

    Leith...I didn't get any output. I clicked run picked the sample file and nothing happened. I appreciate everyone's help

  18. #18
    Registered User
    Join Date
    03-13-2017
    Location
    US
    MS-Off Ver
    2016
    Posts
    13

    Re: Import text file that contains rows into excel as columns

    Since I seem to getting different results with my testing and manage attachments on this site doesn't seem to attach the files to my post here's the link to a sample http://www.filedropper.com/sample2

    @Bernie, unfortunately I didn't get any output.
    Attached Files Attached Files

  19. #19
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    6,351

    Re: Import text file that contains rows into excel as columns

    I wasn't expecting blank lines either. Click the button....
    Attached Files Attached Files

  20. #20
    Registered User
    Join Date
    03-13-2017
    Location
    US
    MS-Off Ver
    2016
    Posts
    13

    Re: Import text file that contains rows into excel as columns

    @Bernie...that's looking good. One more favor to ask. I left some fields off the sample which I don't care about necessarily, but the macro might not play well. I've attached all the row entries. Could you tweak it please? Thank you so much for your help
    Attached Files Attached Files

  21. #21
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    6,351

    Re: Import text file that contains rows into excel as columns

    Just fill out row 1 with the leadins that you want to find and keep - say, it you have

    New Data Point: Bernie

    use

    New Data Point

    in, say, cell F1.

    Any that you don't include in row 1 will be ignored.

    The only other issue that could come up would be lines that don't have : in them. Do you have any like that?

  22. #22
    Registered User
    Join Date
    03-13-2017
    Location
    US
    MS-Off Ver
    2016
    Posts
    13

    Re: Import text file that contains rows into excel as columns

    looks like it only grabs the first row (Row 1 data). Can you try with the real sample data? All lines have a colon. Obviously between Row #s there's a blank line. Thanks
    Last edited by cbiz; 03-14-2017 at 10:53 AM.

  23. #23
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,551

    Re: Import text file that contains rows into excel as columns

    For some reason the site isn't allowing to post the code so the file attached has the code in it. Just copy the code inside the text file and paste inside your workbook.

    Note: Uploaded second txt file because I see your field names have changed. look at Import txt file v2 txt.
    Attached Files Attached Files
    Last edited by mike7952; 03-14-2017 at 11:23 AM.

  24. #24
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    6,351

    Re: Import text file that contains rows into excel as columns

    You should have started with the real headers that you had instead of making up fake ones.
    Attached Files Attached Files

  25. #25
    Registered User
    Join Date
    03-13-2017
    Location
    US
    MS-Off Ver
    2016
    Posts
    13

    Re: Import text file that contains rows into excel as columns

    @Bernie....I apologize for the extra work it caused. I tried on a set of 48 rows, and it worked perfectly. Thanks again

  26. #26
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    6,351

    Re: Import text file that contains rows into excel as columns

    Great - thanks for letting us know that you have a solution to your issue.

+ 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. Import data from Excel file rows into columns
    By potvin48 in forum Excel General
    Replies: 5
    Last Post: 12-02-2014, 01:05 PM
  2. Text file to excel columns import
    By ROHAN999 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-27-2013, 01:44 AM
  3. Import large Hex File and be able to input number of rows and columns to use
    By ssaverin in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-15-2013, 11:03 AM
  4. [SOLVED] Import user selected columns from a text file
    By aarho in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 12-11-2012, 08:28 PM
  5. Import Text File Ddata Into Excel Spreadsheet - Multiple Columns & Rows
    By DOgburn in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-30-2012, 04:45 PM
  6. Import text fields into columns from txt file
    By Pshawn in forum Excel General
    Replies: 3
    Last Post: 01-28-2010, 12:30 PM
  7. Import Text file Fields as Columns in Excel
    By vijay2482 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-12-2009, 11:05 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