I have this macro already set up to choose one .txt file from a folder and then import the data. What I want is to set it up so I can select multiple .txt files and it will go through them one by one and perform the exact same thing on all of them. I just don't know how to set up an appropriate loop. Thanks!

Private Sub cmd1_click()
Dim myFile As Variant, text As String, textline As String, vcd As Integer, viability As Integer, tcd As Integer
Dim batchID As String, filename As String

ChDrive "..."
    ChDir "......"

On Error GoTo Errhandler
myFile = Application.GetOpenFilename()
    
    Open myFile For Input As #1
    
    Do Until EOF(1)
        Line Input #1, textline
        text = text & textline
    Loop
    
    Close #1
    
    batchID = InStr(text, "Sample ID")
    filename = InStr(text, "File name")
    vcd = InStr(text, "Total viable cells")
    viability = InStr(text, "Viability")
    tcd = InStr(text, "Total cells / ml")
    
    Range("batchID").Value = Mid(text, batchID + 12, filename - batchID - 12)
    Range("vcd").Value = Mid(text, vcd + 35, 5)
    Range("viability").Value = Mid(text, viability + 16, 5)
    Range("tcd").Value = Mid(text, tcd + 28, 5)
    
Exit Sub


Errhandler:
    Select Case Err
    Case 53:
        Exit Sub
    Case Else:
        MsgBox ("Error! Did you try to open a non-text file?")
    End Select

        
End Sub