Import single specific delimited column from text file to a userform textbox

I have a text file that has alot of superfluous data in it that i need to pull specific data from using vba. The specific data is listed beneath the CALIBRATION DATA under the "Channel" heading. I only need the channel number and its following comma to be imported to a userform textbox. Additionally, I need there to be no spaces between the different numbers.
example: (2,3,5,7,8)

I have attached the text file I'm using.

Thanks for any help!
29.txt
jcgrooveAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Rgonzo1971Commented:
HI,

pls try

    Sub Macro()
    Open "c:\29.txt" For Input As #1
    ImportTextFile = Input$(LOF(1), 1)
    Close #1
    ImportTextFile = Mid(ImportTextFile, InStr(1, ImportTextFile, "= CALIBRATION DATA =") + 2)
    ImportTextFile = Mid(ImportTextFile, 1, InStr(1, ImportTextFile, vbCrLf & vbCrLf))
    aImportTextFile = Split(ImportTextFile, vbCrLf)
    For Each Item In aImportTextFile
        If Item Like "*#,*" Then
            Res = Res & WorksheetFunction.Clean(Split(Trim(Item), " ")(0))
        End If
    Next
    Debug.Print Res
    End Sub

Open in new window

Regards

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
jcgrooveAuthor Commented:
Thanks! That worked really well. Here is the final product.

Private Sub CommandButton2_Click()
    Dim SelectedFile As String
    With Application.FileDialog(msoFileDialogFilePicker)
    .AllowMultiSelect = False
    .Title = "Select the text file"
    .ButtonName = "Confirm"
    .InitialFileName = "C:\"
    If .Show = -1 Then
    SelectedFile = .SelectedItems(1)
    Open SelectedFile For Input As #1
    ImportTextFile = Input$(LOF(1), 1)
    Close #1
    ImportTextFile = Mid(ImportTextFile, InStr(1, ImportTextFile, "= CALIBRATION DATA =") + 2)
    ImportTextFile = Mid(ImportTextFile, 1, InStr(1, ImportTextFile, vbCrLf & vbCrLf))
    aImportTextFile = Split(ImportTextFile, vbCrLf)
    For Each Item In aImportTextFile
        If Item Like "*#,*" Then
            Res = Res & WorksheetFunction.Clean(Split(Trim(Item), " ")(0))
        End If
    Next
    Else
    Unload Me
    End If
    End With
    TextBox1.Value = Res
    If Right(TextBox1, 1) = "," Then TextBox1 = Left(TextBox1, Len(TextBox1) - 1)
End Sub

Open in new window

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
VB Script

From novice to tech pro — start learning today.