Hi everyone

I have found a code from this forum to import text file, modified it to my need, but stuck on error handling . On error it still adds new sheet , and on No Error it still shows error handler message

Can any one correct it for me

following is the code
Sub Import_Text_File()
    Dim fs As Object ' scripting.filesystemobject
    Dim txtIn As Object ' scripting.textstream
    Dim strFile As String 'File Name
    Dim strLine As String 'Current line being read.
    Dim A As Date
    Dim B As String
    Dim C As String, D As String, E As String, F As String
    Dim iRow As Integer
    Dim spath As String
    Dim oFSO As Object
    Dim fNameAndPath As Variant
    Dim sFileName$
    Dim FileNameWithoutExt As Variant

  Application.ScreenUpdating = False
  
    Set fs = CreateObject("scripting.FileSystemObject")
    iRow = 2

fNameAndPath = Application.GetOpenFilename(FileFilter:="Load Profile Files (*.LP), *.lp", Title:="Select Load Profile File (ISKARA Meter)")
If fNameAndPath = False Then Exit Sub

sFileName = Split(fNameAndPath, "\")(UBound(Split(fNameAndPath, "\")))
FileNameWithoutExt = Left(sFileName, InStrRev(sFileName, ".") - 1)
  
strFile = fNameAndPath
On Error GoTo Errorhandler
Sheets.Add.Name = FileNameWithoutExt

    Set txtIn = fs.openTextFile(strFile, 1) ' 1 ForReading
 
        Do While Not txtIn.AtEndOfStream
            strLine = txtIn.ReadLine
       If InStr(1, strLine, "MWh") Or InStr(1, strLine, "ISKMT") Then
       strLine = Delete
       ElseIf InStr(1, strLine, "P.01") Then
       A = DateSerial(Mid(strLine, 6, 2), Mid(strLine, 8, 2), Mid(strLine, 10, 2))
       B = TimeSerial(Mid(strLine, 12, 2), Mid(strLine, 14, 2), 0)
       strLine = Delete
       Else
       
        C = Val(Mid(strLine, 2, 9))
        D = Val(Mid(strLine, 13, 9))
        E = Val(Mid(strLine, 24, 10))
        F = Val(Mid(strLine, 35, 10))
        G = A + B
        
 
            Cells(iRow, 2) = A
            Cells(iRow, 3) = B
            Cells(iRow, 3).NumberFormat = "HH:MM"
            Cells(iRow, 4) = C
            Cells(iRow, 5) = D
            Cells(iRow, 6) = E
            Cells(iRow, 7) = F
            Cells(iRow, 1) = G
            Cells(iRow, 1).NumberFormat = "dd-mmm-yyyy  hh:mm"
            
            
            
       B = (Cells(iRow, 3) + 1 / 24 / 2)
              
            iRow = iRow + 1
       
       
       End If
       
        Loop
        Cells(1, 2) = "Date"
        Cells(1, 3) = "Time"
        Cells(1, 4) = "MWh Import"
        Cells(1, 5) = "MWh Export"
        Cells(1, 6) = "MVAR Import"
        Cells(1, 7) = "MVAR Export"
        Cells(1, 1) = "Time Stamp"
        
      Columns.AutoFit
      
Application.ScreenUpdating = True
Errorhandler:
      msgbox "File is already imported." & Chr(13) & " Plz Try different one"

End Sub