Olá a todos.
Eu tentei criar um código para deletar um uma determinada quantidade de linhas na condição de me voltar o nome perguntado.
Ela roda até certo ponto.
Se apertar ESC ela cancela.
Se não digitar nada ela funciona.
Se digitar o nome correto ela funciona e dela.
Mas...
Se digitar qualquer outro nome diferente do procurado da erro.
Segue codigo abaixo:
Sub DELETARFUNCIONARIO()
Application.ScreenUpdating = False
ActiveSheet.Unprotect
showInputBox:
Resp = Application.InputBox("Digite o nome do funcionário para excluir", "EXCLUIR")
Cont = Range("AJ16:AT200").Select
If Resp = False Then
MsgBox "Operação cancelada!"
End
Else
If Resp = Empty Then
MsgBox "Campo Vazio. É necessário digitar um nome!"
GoTo showInputBox
End If
End If
Range("AJ16:AT200").Select
Cells.Find(What:=Resp).Activate
Lin = ActiveCell.Row
Rows(Lin).Select
Selection.EntireRow.Delete Shift:=x1up
Range("AJ16:AT200").Select
Cells.Find(What:=Resp).Activate
Lin = ActiveCell.Row
Rows(Lin).Select
Selection.EntireRow.Delete Shift:=x1up
Range("AJ16:AT200").Select
Cells.Find(What:=Resp).Activate
Lin = ActiveCell.Row
Rows(Lin).Select
Selection.EntireRow.Delete Shift:=x1up
Range("AJ16:AT200").Select
Cells.Find(What:=Resp).Activate
Lin = ActiveCell.Row
Rows(Lin).Select
Selection.EntireRow.Delete Shift:=x1up
Range("AJ16:AT200").Select
Cells.Find(What:=Resp).Activate
Lin = ActiveCell.Row
Rows(Lin).Select
Selection.EntireRow.Delete Shift:=x1up
Range("AJ16:AT200").Select
Cells.Find(What:=Resp).Activate
Lin = ActiveCell.Row
Rows(Lin).Select
Selection.EntireRow.Delete Shift:=x1up
Range("AJ16:AT200").Select
Cells.Find(What:=Resp).Activate
Lin = ActiveCell.Row
Rows(Lin).Select
Selection.EntireRow.Delete Shift:=x1up
Range("AJ16:AT200").Select
Cells.Find(What:=Resp).Activate
Lin = ActiveCell.Row
Rows(Lin).Select
Selection.EntireRow.Delete Shift:=x1up
Range("AJ16:AT200").Select
Cells.Find(What:=Resp).Activate
Lin = ActiveCell.Row
Rows(Lin).Select
Selection.EntireRow.Delete Shift:=x1up
Cells.FormatConditions.Delete
'Mostrar Menu
Application.ExecuteExcel4Macro "SHOW.TOOLBAR(""Ribbon"",False)"
'Barra de Fórmulas
Application.DisplayFormulaBar = False
'Barra de Status
Application.DisplayStatusBar = False
'Cabeçalhos
ActiveWindow.DisplayHeadings = False
'Guias de planilhas
ActiveWindow.DisplayWorkbookTabs = False
'Linhas de grade
ActiveWindow.DisplayGridlines = False
Call ALERTA
Call COLORPASSAGEM
Call ATRASADO
Call COLORPAGOINTERNO
Call NEUTRO1
Call NEUTRO
Call CMVCOLORGREEN
Call CMVCOLORRED
Call COLORSTATUSGREEN
Call COLORSTATUSRED
Call SELECAO
Call PAGO
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True, AllowSorting:=True, AllowFiltering:=True
ActiveSheet.EnableSelection = xlUnlockedCells
Range("AJ16").Select
End Sub