Error in search box blocked worksheet

0

The command is great, but I include a search command with box box and every time I search if the worksheet is locked with password the search does not work. Well, informs that you need to unlock the worksheet, can you help me?

Private Sub Codigo_Change()
    If Codigo.Text <> "" Then
        Selection.AutoFilter Field:=1, Criteria1:="=" & Codigo.Text
    Else
        Selection.AutoFilter Field:=1
    End If
End Sub

Private Sub Comprador_Change()
    If Comprador.Text <> "" Then
        Selection.AutoFilter Field:=2, Criteria1:="=" & Comprador.Text
    Else
        Selection.AutoFilter Field:=2
    End If
End Sub

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

    Dim vStrLocaisProibidos As String
    Dim vRngReturn As Variant
    Dim vMaxError As Long

    'definido para parar depois que a macro tenta colocar um novo local
    'depois de 10 tentativas. Ele para e mantem o cursor a onde for.
    vMaxError = 10
    vStrLocaisProibidos = "C:C,C5:C127,D:D,D5:D127,E:E,E5:E127,F:F,F5:F127,I:I,I5:I127,M:M,M5:M127,Q:Q,Q5:Q127"

    If vStrLocaisProibidos = vbNullString Then Exit Sub
    Set vRngReturn = Application.Intersect(Target.Worksheet.Range(vStrLocaisProibidos), Target)

    If Not vRngReturn Is Nothing Then
        Beep
        If vErrLineMove < vMaxError Then
            vErrLineMove = vErrLineMove + 1
            Cells(Target.Row, Target.Column).Offset(0, 1).Select
        End If
    End If

    vErrLineMove = 0

End Sub
    
asked by anonymous 06.12.2018 / 19:03

0 answers