Haven't started on it yet.
I'm currently at work and will write the script when I get home tonight.
Google has been great in providing the solutions for the intermediate steps, but I just can't get the looping part down.
Haven't started on it yet.
I'm currently at work and will write the script when I get home tonight.
Google has been great in providing the solutions for the intermediate steps, but I just can't get the looping part down.
Here is a sample of the text file that I am using:
Company Name: Pears Galore
Revenue: $500,000
The code
I took this code off someone else and edited to make it mine. However, I am not sure what can be done to make it loop for multiple text files, and insert the revenue figures into a column.![]()
Sub GetInfoFromText() Dim X As Long, FilePathAndName As String, TotalFile As String, FileNum As Long, Arr() As String Dim CompanyName As String, Revenue As String ' Get path and filename by whatever means you do now FilePathAndName = "C:\Users\revenue.txt" ' Read entire file into TotalFile variable FileNum = FreeFile Open FilePathAndName For Binary As #FileNum TotalFile = Space(LOF(FileNum)) Get #FileNum, , TotalFile Close #FileNum ' Get Company Name Arr = Split(TotalFile, "Company Name: ") CompanyName = Split(Arr(1), vbCrLf)(0) ' Get Revenue Arr = Split(TotalFile, "Revenue: ") Revenue = Split(Arr(1), vbCrLf)(0) ActiveCell = CompanyName ActiveCell.Offset(1) = Revenue End Sub
Is it also possible to automatically input the file path and name? or would this have to be done manually?
Last edited by WinningKing; 02-20-2014 at 08:49 AM.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks