Option Explicit
Private Function SansAccents(chn$) As String
Dim c01$, c02$, p%
For p = 1 To Len(chn)
c01 = Mid$(chn, p, 1): c02 = "@"
Select Case c01
Case "á", "à", "â", "ä", "ã", "å": c02 = "a"
Case "é", "è", "ê", "ë": c02 = "e"
Case "í", "ì", "î", "ï": c02 = "i"
Case "ó", "ò", "ô", "ö", "õ", "ø": c02 = "o"
Case "ú", "ù", "û", "ü": c02 = "u"
Case "ñ": c02 = "n"
Case "ç": c02 = "c"
Case "š": c02 = "s"
Case "ý", "ÿ": c02 = "y"
Case "ž": c02 = "z"
End Select
If c02 <> "@" Then Mid$(chn, p, 1) = c02
Next p
SansAccents = chn
End Function
Private Sub IndexFX(gst$, idx%)
Dim chn$, i%: idx = 0
For i = 2 To Worksheets.Count
chn = Worksheets(i).Name
chn = Right$(chn, Len(chn) - 2)
If chn <> "" Then
chn = SansAccents(LCase$(chn))
If chn = LCase$(gst) Then idx = i: Exit For
End If
Next i
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
Dim tck As Range, cel As Range, gst1$, gst2$, idx%, lig&
With Target
If .CountLarge > 1 Then Exit Sub
If .Column <> 2 Then Exit Sub
lig = .Row: If lig < 11 Then Exit Sub
If (lig - 3) Mod 9 <> 8 Then Exit Sub
Set tck = .Offset(-8, -1): gst2 = .Value
End With
With Application
.ScreenUpdating = 0: .EnableEvents = 0: .Undo
gst1 = Target: Target = gst2: .EnableEvents = -1
End With
If gst1 <> "" And (gst2 = "" Or gst2 <> gst1) Then
IndexFX gst1, idx
If idx > 0 Then
With Worksheets(idx)
Set cel = .Columns(1).Find(tck, , -4163, 1, 1)
If Not cel Is Nothing Then .Rows(cel.Row).Delete
End With
End If
End If
If gst2 = "" Then Exit Sub
IndexFX gst2, idx: If idx = 0 Then Exit Sub
With Worksheets(idx)
lig = .Cells(Rows.Count, 1).End(3).Row + 1
.Cells(lig, 1) = tck
End With
End Sub