I am currently working on a data extraction project. The program will prompt user to enter the number of text files they want to extract. Afterwards, the user will select the files they want. However, the data extracted is only based on the first text file selected. How do I go about solving this issue.
Private Sub CommandButton1_Click()
Dim fileStringBasic As String
Dim i As Integer
Dim k As Integer
Dim iFile As Integer: iFile = FreeFile
k = InputBox("Give me some input")
For i = 1 To k
fileStringBasic = Application.GetOpenFilename()
If fileStringBasic <> "False" Then
Open fileStringBasic For Input As #iFile
Do Until EOF(iFile)
Line Input #iFile, textline
Text = Text & textline
Loop
Close #iFile
pos1 = InStr(Text, "Datalog report")
pos2 = InStr(Text, "BOARD PN")
pos3 = InStr(Text, "BOARD SN")
pos4 = InStr(Text, "TESTER")
pos5 = InStr(Text, "DEVICE")
pos6 = InStr(Text, "USER NAME")
Range("A" & ActiveCell.Row).Value = Mid(Text, pos1 + 18, 11)
Range("B" & ActiveCell.Row).Value = Mid(Text, pos2 + 18, 10)
Range("D" & ActiveCell.Row).Value = Mid(Text, pos3 + 18, 8)
Range("E" & ActiveCell.Row).Value = Mid(Text, pos4 + 18, 9)
Range("F" & ActiveCell.Row).Value = Mid(Text, pos5 + 18, 11)
Range("H" & ActiveCell.Row).Value = Mid(Text, pos6 + 18, 11)
End If
Selection.Offset(1, 0).Select
Next i
End Sub