+ Reply to Thread
Results 1 to 3 of 3

Import specific data from multiple text files to an excel spreadsheet

  1. #1
    Registered User
    Join Date
    02-01-2012
    Location
    Auckland, New Zealand
    MS-Off Ver
    Excel 2010
    Posts
    2

    Import specific data from multiple text files to an excel spreadsheet

    Hi everyone,

    This marks my first post in these forums! Normally I persevere and work on these problems until I crack them but I feel a little out of my depth on this one and don't really have the time either.

    So here is my problem: I have a folder containing text files, 300 of them to be exact. I need to open them one by one and copy some of the data into an excel spreadsheet. These text files are pretty huge, some of them over 100,000 lines so you can't just import them into a spreadsheet as they go over the 65,536 row limit.

    Here is a sample of the data:

    10.209.32.200, FPHCARE\chani, 4/7/2011, 12:15:18, W3SVC1008243123, HERALD, 10.201.10.26, 218, 6681, 473, 200, 0, GET, /_security/initUser.asp, -,
    10.209.32.200, -, 4/7/2011, 12:15:18, W3SVC1008243123, HERALD, 10.201.10.26, 15, 903, 1872, 401, 2148074254, GET, /Application/Drawing/Default.asp, -,
    10.209.32.200, FPHCARE\chani, 4/7/2011, 12:15:18, W3SVC1008243123, HERALD, 10.201.10.26, 124, 6690, 591, 302, 0, GET, /Application/Drawing/Default.asp, -,
    10.209.32.200, -, 4/7/2011, 12:15:18, W3SVC1008243123, HERALD, 10.201.10.26, 0, 903, 1872, 401, 2148074254, GET, /Application/Drawing/Content.asp, -,
    10.209.32.200, FPHCARE\chani, 4/7/2011, 12:15:18, W3SVC1008243123, HERALD, 10.201.10.26, 249, 6690, 7683, 200, 0, GET, /Application/Drawing/Content.asp, -,
    10.209.32.200, -, 4/7/2011, 12:15:18, W3SVC1008243123, HERALD, 10.201.10.26, 0, 642, 1872, 401, 2148074254, GET, /_common/fp_hcr.css, -,
    10.209.32.200, -, 4/7/2011, 12:15:18, W3SVC1008243123, HERALD, 10.201.10.26, 0, 645, 1872, 401, 2148074254, GET, /_scripts/menu/menu.js, -,

    What I need to do is scan each line for the string "drawing/content" (not case sensitive, highlighted in red) and if it matches, scan earlier in the line for a username (highlighted in green). The username will always follow the string "FPHCARE\" and will always be followed by a comma ",". I then need to copy this username into a column in a spreadsheet so that there is a list of them. This list needs to only contain unique names so that if one already exists, it will not be added again to the bottom. Note that some of the lines that contain "drawing/content" will not contain a username, but instead will have a dash "-" (highlighted in orange - if you can see it). These matches should be ignored.

    The final requirement is that if a username is scanned but already exists in the column, a count of the number if instances of that username begins in the column next to it. i.e. every time that username is scanned, the number in the cell next to it increases by one. Here is an image to demonstrate what I mean:

    excelexample.jpg

    My VBA skills are fairly low-level but I am always keen to learn. So if any more experienced users have any good ideas on how to approach this or have any juicy solutions they would like to share, I am all ears (or all eyes, as the case may be)

    Thanks,
    Phil
    Last edited by NBVC; 02-02-2012 at 04:55 PM.

  2. #2
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591

    Re: Import specific data from multiple text files to an excel spreadsheet

    Hi

    See how this goes. You will have to have excel opened at the path where the text files are found.

    Please Login or Register  to view this content.
    rylo

  3. #3
    Registered User
    Join Date
    02-01-2012
    Location
    Auckland, New Zealand
    MS-Off Ver
    Excel 2010
    Posts
    2

    Re: Import specific data from multiple text files to an excel spreadsheet

    Rylo,

    You my friend... are a legend. Thank you so much, this code is perfect.

    I think that hardest aspect for me is that I don't know the VBA functions and what they can do. It's fairly easy to follow when I read your solution though.

    Thanks again mate,

    Phil

+ 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