Option Explicit
Sub travdem()
Dim cellule As Range
Dim nomfeuille1 As String
Dim dl1 As Long
Dim lig As Long
Dim data1 As String
' pour boucler sur la colonne 1
dl1 = Sheets("Tabelle2").Cells(Sheets("Tabelle2").Columns(4).Cells.Count, 4).End(xlUp).Row + 1
With Sheets("Tabelle1")
For Each cellule In .Range("b2:b" & .Cells(Columns(2).Cells.Count, 2).End(xlUp).Row)
If cellule.Value <> "" Then
lig = chercheligne("Tabelle2", cellule.Value, "d3", "d" & dl1)
If lig > 0 And Sheets("Tabelle2").Range("f" & lig) <> "" Then
On Error Resume Next
cellule.ClearComments
cellule.AddComment
cellule.Comment.Text Text:= Sheets("Tabelle2").Range("f" & lig)
cellule.Comment.Visible = False
'With cellule.Comment.Shape
'.Width = 130 'Largeur commentaire
'.Height = 90 'Hauteur
'.OLEFormat.Object.Font.Size = 14 'Taille du texte
'.OLEFormat.Object.Interior.ColorIndex = 34 'Couleur de fond
'.TextFrame.Characters.Font.ColorIndex = 11 'Couleur de la police
'.TextFrame.Characters.Font.Bold = True 'Ecriture gras
'.OLEFormat.Object.Font.Name = "Bangle" 'Type de police
'End With
End If
End If
Next cellule
End With
End Sub
Function chercheligne(£feuille As String, £valeur As String, £col1d As String, £col1f As String)
Dim cel As Range
Set cel = Sheets(£feuille).Range(£col1d & ":" & £col1f).Find(What:=£valeur, LookIn:=xlValues, SearchOrder:=xlByRows, LookAt:=xlWhole)
If cel Is Nothing Then
chercheligne = 0
Else
chercheligne = cel.Row
End If
End Function