see if this helps:
in the VB line:
ActiveWorkbook.Names.Add Name:=a, RefersToR1C1:=d
try this:
ActiveWorkbook.Names.Add Name:=a, RefersTo:= _
"=" & d
this "space underline space", at the end of the vb line, forces the function
'build' to continue 'wrap' to the next line!
Not sure why this worked!