kkmoslephour
New Member
- Joined
- May 8, 2014
- Messages
- 27
Hi all,
I am trying to read in a text file and split it by character spaces and output to excel sheet, right now I can read in the text file, but I am having problem splitting it into an array by character spaces. Here is my vba code:
below is a portion of my text file (as you can see the text file spacing isn't consistent)
DESCRIPTION C.QTY R.QTY H/W P/N SW Ver SW P/N CONFIG
==============================================================================
44 XXX XXX XXX 2 2 XX-XX8888-88 01.25.00.7MEI4B-8888-8888888888E
44 YYY YYYYYY YYY 2 NULL 01.05.00.7MEI4D-9999-4001NULL
44 ZZZ ZZZZ ZZZZ ZZZZ000 00 NULL 01.02.00.7MEI00-0000-0000NULL
I am trying to read in a text file and split it by character spaces and output to excel sheet, right now I can read in the text file, but I am having problem splitting it into an array by character spaces. Here is my vba code:
Code:
Sub ParseText()
Dim myFile As String, text As String, textline As String
myFile = Application.GetOpenFilename("Text Files (*.txt), *.txt")
MsgBox myFile
If myFile <> "False" Then
MsgBox "Opening " & myFile
End If
Open myFile For Input As #1
Do Until EOF(1)
Line Input #1, textline
MsgBox textline
text = text & textline
MsgBox text
Loop
Close #1
End Sub
below is a portion of my text file (as you can see the text file spacing isn't consistent)
DESCRIPTION C.QTY R.QTY H/W P/N SW Ver SW P/N CONFIG
==============================================================================
44 XXX XXX XXX 2 2 XX-XX8888-88 01.25.00.7MEI4B-8888-8888888888E
44 YYY YYYYYY YYY 2 NULL 01.05.00.7MEI4D-9999-4001NULL
44 ZZZ ZZZZ ZZZZ ZZZZ000 00 NULL 01.02.00.7MEI00-0000-0000NULL