Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim a(), ub&, c As Range, n&
With [B1:M13]
ReDim a(1 To Application.Count(.Value))
ub = UBound(a)
For Each c In .Cells
n = n + 1
If n <= ub Then a(n) = c
Next
End With
ThisWorkbook.Names.Add "Y", a
With [B38:M50]
n = 0
For Each c In .Cells
n = n + 1
If n <= ub Then a(n) = c
Next
End With
ThisWorkbook.Names.Add "X", a
End Sub