Private Sub Worksheet_Change(ByVal Target As Range)
Dim i&, X(), Y(), n&
If FilterMode Then ShowAllData 'si la feuille est filtrée
With Range("A1", Range("B" & Rows.Count).End(xlUp)) 'à adapter
For i = 2 To .Rows.Count
If .Cells(i, 1) <> "" And .Cells(i, 2) > 0 Then
ReDim Preserve X(n): ReDim Preserve Y(n) 'base 0
X(n) = .Cells(i, 1): Y(n) = .Cells(i, 2)
n = n + 1
End If
Next
End With
'---noms définis---
If n Then ThisWorkbook.Names.Add "X", X: ThisWorkbook.Names.Add "Y", Y _
Else ThisWorkbook.Names.Add "X", "={""n/a""}": ThisWorkbook.Names.Add "Y", "={0}"
End Sub