Bug? CreateNames default values in VBA is NOT default?

boim

Board Regular
Joined
Dec 14, 2009
Messages
54
According to Excel Help, the arguments of CreateNames method are optional:
Remarks

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.

yet I found that even after I specify one, in VBA, Excel STILL guesses for the text labels. This happens only when the values are texts.


So for example, I have two columns range, say "A:B". "A" contains text for the Names and "B" contains text for formulas:
A_________B
Speed_____Distance / Time
Accel______Speed / Time
etc...

I created names in VBA:
Code:
Range("A1:B5").CreateNames Left:=True

and it didn't work. Excel will guess sometimes the first row to be labels too and sometimes the last row, eventhough I'd already specified Left:=True. I had to specify all other arguments to False to get it right. Is this a bug? Again, it doesn't happen if "B" contains numbers.
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
I always figure that if I don't specify it, I can't complain when Excel doesn't do it. (Hence, my underuse of default or automatic proceedures.)

If you can get what you want by specifying all four arguments, then that would be the way to go.
 
Upvote 0
Man... I can only imagine about other functions that have many arguments. I was trying to clean up my code to look neater till I found it stopped working and traced it to that error in the CreateNames line.

I always figure that if I don't specify it, I can't complain when Excel doesn't do it.

True, but it makes things harder since it doesn't do what it says it does.
 
Upvote 0
Remarks

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.

The key word there is "Guesses"

What you think Excel should do, is not necessarily what Excel thinks it should do (if you can call what Excel does "Think")
 
Upvote 0

Forum statistics

Threads
1,214,535
Messages
6,120,093
Members
448,944
Latest member
SarahSomethingExcel100

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top