Private Sub Worksheet_Activate()
Dim ncol%, i%
With Sheets("Data").[A1].CurrentRegion
ncol = .Columns.Count - 1
If ncol Then 'si au moins 2 colonnes
ReDim resu(1 To ncol, 1 To 3)
For i = 1 To ncol
resu(i, 1) = .Cells(1, i + 1)
resu(i, 2) = Application.Average(.Columns(i + 1)) 'moyenne
resu(i, 3) = Application.StDev(.Columns(i + 1)) 'écart-type
Next
End If
End With
'---restitution---
Application.EnableEvents = False 'désactive les évènements
If FilterMode Then ShowAllData 'si la feuille est filtrée
With [A2] '1ère cellule de restitution, à adapter
If ncol Then .Resize(ncol, 3) = resu
.Offset(ncol).Resize(Rows.Count - ncol - .Row + 1, 3).ClearContents 'RAZ en dessous
End With
Application.EnableEvents = True 'réactive les évènements
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
Worksheet_Activate 'lance la macro
End Sub