Sub Savedatabase()
Dim i4 As Integer
Dim plagesaisie As Range, re As Range, tve As Range, z As Range, plge As Range, plge2 As Range
Dim Tiu%, esp%, Tc%
Set sa = Worksheets("Saisie")
Set co = Worksheets("Correspondances")
lrco = co.Cells(Rows.Count, 1).End(xlUp).Row
lcco = co.Cells(1, co.Columns.Count).End(xlToLeft).Column
lrsa = sa.Cells(Rows.Count, 1).End(xlUp).Row
For Tiu = 1 To lcco ' cherche identifiant unique
If co.Cells(1, Tiu) = "Identifiant unique" Then
Set plge = co.Range(Cells(1, Tiu), Cells(lrco, Tiu)) ' set plage identifiant unique
Exit For
End If
Next Tiu
' For Tc = 1 To lcco ' cherche correspondance
' If co.Cells(1, Tc) = "Correspondance" Then
' Set plge2 = co.Range(Cells(1, Tc), Cells(lrco, Tc)) ' set plage correspondance
' Exit For
' End If
' Next Tc
' Set plagesaisie = Cells(tve, lrco) 'tve
For Tc = 1 To lcco ' cherche correspondance
If co.Cells(1, Tc) = "Correspondance" Then
For esp = 1 To lcco ' cherche especes
If co.Cells(1, esp) = "especes" Then
With sa
For i4 = 2 To lrsa
Set re = plge.Find(.Cells(i4, 1), lookat:=xlWhole)
If Not re Is Nothing Then
.Cells(i4, 2) = re.Offset(, Tc - Tiu) 're.Offset(, 4) 're.Offset(, Tc - Tiu) ' colonne identifiant unique moins colonne correspondance
.Cells(i4, 4) = re.Offset(, esp - Tiu)
Else
End If
Next
End With
Exit For
End If
Next esp
Exit For
End If
Next Tc
End Sub