当出现错误时,我的代码在每一行之后都会返回到 goto

My code keeps going back to the goto after every line when there is an error

我有以下代码:

On Error GoTo no_match
found_discord = Application.WorksheetFunction.Match(char, table_rng.ListColumns("Chars").DataBodyRange, 0)
discord = table_rng.DataBodyRange(found_discord, 8).Value

If discord = "" Then

    answer = MsgBox("This user has no discord on file. Do you know his discord?", vbYesNo)
    
    If answer = "yes" Then
        
        discord = InputBox("Please type user discord:")
    
        
        If (Me.OptForever.Value = True And discord = "") Then
        
            discord = "Banned Forever"
        
        End If
        
    Else
        
        If Me.OptForever.Value = True Then
        
            discord = "Banned Forever"
        
        Else
        
            discord = "No disc found"
        
        End If
    
    End If
    
End If

Set lrow = table_notes.ListRows.Add
    
With lrow
        
    .Range(1) = char
    .Range(2) = length
    .Range(3) = Date
    .Range(4) = end_time
    .Range(6) = reason
    .Range(7) = discord
            
End With

Check_discord discord, char, length, end_time, reason

sort_table4

lock_pass

Unload Me
Exit Sub

no_match:
    MsgBox ("This Char is new to our database please insert data after clicking ok")
    frmNewChar.Show
    found_discord = Application.WorksheetFunction.Match(char, table_rng.ListColumns("Chars").DataBodyRange, 0)
    discord = table_rng.DataBodyRange(found_discord, 8).Value
    Resume Next
    
End Sub

代码的思路是使用匹配函数来查找值。 (这部分工作正常)。

我的问题是 Match 函数找不到匹配项。 而不是 运行 “no_match” 区域中的代码一次,然后继续其余代码, VBA 在“if”语句之后的每一行之后跳转到“no_match”。

有人能帮帮我吗?

在匹配函数行后添加以下内容

on error goto 0