Read a Text File with VBA into Excel

Mel2016

New Member
Joined
Jun 5, 2016
Messages
41
I have a huge text file that I want to extract specific data and put each one it into a column in excel. I not even sure how to start. I've only done simple code in excel before.

The data in the text file looks like the following
date. Report name Page number
time

run option:
print option:

class
User Name
________________________

Abcd Joe smith


I only need class and users by class but each class has a different number of users.

Thanks for any help
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
Have you tried importing the data from the text file and then using the data import wizard?
 
Upvote 0
Oh yes, tried recording a macro and that got all messed up. My problem is that the class is above the user information and I need it by each userid. So I would have 3 columns in a spreadsheet. But since it's a text file there are so many empty lines I don't know where to start.
 
Upvote 0
Date 11/04/16 User Information Listing Page 1
Time 15:23


RUN OPTION: USER LISTING
PRINT OPTION: NO SYSTEMS


Security Class:


USER NAME
------------------------------ --------------------------------------------------
NT AUTHORITY\SYSTEM
PRODCEAD\ip4567 George Chatty


Security Class: ABSCGEN


USER NAME
------------------------------ --------------------------------------------------
PRODCEAD\GOJOBF GFig
PRODCEAD\MA3593 Sherain Doweary
PRODCEAD\rp7645 Kristin M. Penny
PRODCEAD\tm0477 Kayla Ykins
PRODCEAD\wk1948 Meg Mole
PRODCEAD\iz5555 Lynda Brown


Security Class: ABSIGEN


USER NAME
------------------------------ --------------------------------------------------
PRODCEAD\tn2144 Anne L. Phill
PRODCEAD\jg1353 Kersha Johnsont


Security Class: ADMIN


USER NAME
------------------------------ --------------------------------------------------
PRODCEAD\SYSTEM ADMIN


Security Class: AGACTSSOQ


USER NAME
------------------------------ --------------------------------------------------
PRODCEAD\M0ES27 Nancy Drew
Date 11/04/16 User Information Listing Page 2
Time 15:23


RUN OPTION: USER LISTING
PRINT OPTION: NO SYSTEMS


Security Class: AGACTSSOQ


USER NAME
------------------------------ --------------------------------------------------
 
Upvote 0
Now this is an example but it did get messed up a bit. the User and Name have space between them
 
Upvote 0

Forum statistics

Threads
1,214,649
Messages
6,120,733
Members
448,987
Latest member
marion_davis

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top