Range.CreateNames (Excel)

Creates names in the specified range, based on text labels in the sheet.

If you don't specify one of Top, Left, Bottom, or Right, Microsoft Excel guesses the location of the text labels, based on the shape of the specified range.

CreateNames (Top, Left, Bottom, Right)


Set rangeToName = Worksheets("Sheet1").Range("A1:B3") 
rangeToName.CreateNames Left:=True

Arguments

Optional arguments

The following arguments are optional

Top (Boolean) - True to create names by using labels in the top row. The default value is False.

Left (Boolean) - True to create names by using labels in the left column. The default value is False.

Bottom (Boolean) - True to create names by using labels in the bottom row. The default value is False.

Right (Boolean) - True to create names by using labels in the right column. The default value is False.