Excel VBA met à jour la date dans une cellule si quelque chose change dans une gamme de cellules dans la même rangée

J'ai un code où la date est mise à jour dans la cellule dans la colonne D si une modification a été effectuée dans la cellule dans la même rangée dans la colonne F:

Private Sub Worksheet_Change(ByVal Target As Range) ' Code to put the date of the latest update following a change in the corresponding cell in column F Dim WorkRng As Range Dim rng As Range Dim xOffsetColumn As Integer Set WorkRng = Intersect(Application.ActiveSheet.Range("F:F"), Target) xOffsetColumn = -2 'The date is put 2 columns to the left of column F If Not WorkRng Is Nothing Then Application.EnableEvents = False For Each rng In WorkRng If Not VBA.IsEmpty(rng.Value) Then rng.Offset(0, xOffsetColumn).Value = Now rng.Offset(0, xOffsetColumn).NumberFormat = "dd/mm/yyyy" Else rng.Offset(0, xOffsetColumn).ClearContents End If Next Application.EnableEvents = True End If End Sub 

Maintenant, je dois adapter ce code afin que la date soit mise à jour dans la cellule de la colonne D si une modification a été effectuée dans les cellules de la même rangée dans les colonnes F à K.

J'ai très peu de connaissances VBA et je serais reconnaissant de toute aide pour l'adaptation du code.

Cela semble fonctionner:

 Private Sub Worksheet_Change(ByVal Target As Range) ' Code to put the date of the latest update following a change in the corresponding cell in column F Dim WorkRng As Range, roww As Long Dim rng As Range Set WorkRng = Intersect(Range("F:K"), Target) If Not WorkRng Is Nothing Then Application.EnableEvents = False For Each rng In WorkRng roww = rng.Row If Not rng.Value = "" Then Cells(roww, "D").Value = Now Cells(roww, "D").NumberFormat = "dd/mm/yyyy" Else Cells(roww, "D").ClearContents End If Next Application.EnableEvents = True End If End Sub 

Nous n'utilisons pas simplement OFFSET()