Private Sub Worksheet_Change(ByVal Target As Range)
'Paste this to the worksheet module of the sheet where you want to have the named ranges
Dim X As Range
Dim Y As Range
Application.EnableEvents = False 'Disables events - just to be sure
'The ranges on active sheet:
Set X = Range("A31")
Set Y = Range("A32")
'Adds the ranges to Names:
With ActiveWorkbook.Names
.Add Name:="X", RefersToR1C1:=X
.Add Name:="Y", RefersToR1C1:=Y
End With
Application.EnableEvents = True 'Turns the events back on
End Sub