Error to read

Peter_1985 2,466 Reputation points
2021-03-24T04:03:51.36+00:00

Hi,
Please help to error
81003-a20.png
due to last line below

    If Trim(TextLine) <> "" Then    
        Pos0 = InStr(TextLine, ",")    
        Pos1 = InStr(Pos0 + 1, TextLine, ",")    
        Pos2 = InStr(Pos1 + 1, TextLine, ",")    
        Pos3 = InStr(Pos2 + 1, TextLine, ",")    
        Pos4 = InStr(Pos3 + 1, TextLine, ",")    
        Pos5 = InStr(Pos4 + 1, TextLine, ",")    
        Pos6 = InStr(Pos5 + 1, TextLine, ",")    
        Pos7 = InStr(Pos6 + 1, TextLine, ",")    
        Pos8 = InStr(Pos7 + 1, TextLine, ",")    
        Pos9 = InStr(Pos8 + 1, TextLine, ",")    
        Pos10 = InStr(Pos9 + 1, TextLine, ",")    
            
        Pos2 = Len(TextLine)    
        If Not Pos0 > 0 And Not Pos1 > 0 Then    
            Para_Message = "Invalid line -'" & TextLine & "' has been got from list file."    
            MsgBox Para_Message    
            Close #iFile    
            Exit Sub    
        Else    
            
            RowID = RowID + 1    
            Worksheets("Main").Unprotect Password:="hkg1317"    
            Worksheets("Main").Cells(RowID, 1).Value = Mid(TextLine, 1, Pos0 - 1)    
            Worksheets("Main").Cells(RowID, 2).Value = Mid(TextLine, Pos0 + 1, Pos1 - Pos0 - 1)    
            Worksheets("Main").Cells(RowID, 3).Value = Mid(TextLine, Pos1 + 1, Pos2 - Pos1 - 1)    
            Worksheets("Main").Cells(RowID, 4).Value = Mid(TextLine, Pos2 + 1, Pos3 - Pos2 - 1)    

TextLine is line below

"NZ2,ABC,6,N,TWKLG,8501,8529,1,,"

{count} votes

0 additional answers

Sort by: Most helpful