Sub SauverCommentaires()
Dim t(1 To 4)
Dim c As Range, cDest As Range
For Each c In Sheets("Feuil1").Range("B2:EN2000").Cells
If Not c.Comment Is Nothing Then
t(1) = c.Parent.Cells(c.Row, 1) ' la date
t(2) = c.Parent.Cells(1, c.Column) ' la machine
t(3) = c
'il faut absolument que la ligne de détails soit la 4ème ligne du commentaire
t(4) = Split(c.Comment.Text, vbLf)(3)
Sheets("sauvegardes").Range("A" & Application.Rows.Count).End(xlUp)(2).Resize(, 4).Value = t
Erase t
End If
Next
End Sub
Sub SauverCommentairesMoinsRapideMaisUnPeuPlusSur()
Dim t(1 To 4), tComm As Variant
Dim i As Long
Dim c As Range, cDest As Range
For Each c In Sheets("Feuil1").Range("B2:EN2000").Cells
If Not c.Comment Is Nothing Then
t(1) = c.Parent.Cells(c.Row, 1) ' la date
t(2) = c.Parent.Cells(1, c.Column) ' la machine
t(3) = c
t(4) = "détails non trouvé" 'valeur par défaut
tComm = Split(c.Comment.Text, vbLf)
If IsArray(tComm) Then
For i = UBound(tComm) To UBound(tComm)
If LCase(tComm(i)) Like "détails:*" Then
t(4) = tComm(i)
Exit For
End If
Next
End If
Sheets("sauvegardes").Range("A" & Application.Rows.Count).End(xlUp)(2).Resize(, 4).Value = t
If IsArray(tComm) Then Erase tComm
End If
Next
End Sub