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.
 

mikerickson

MrExcel MVP
Joined
Jan 15, 2007
Messages
22,776
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.
 

boim

Board Regular
Joined
Dec 14, 2009
Messages
54
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.
 

mikerickson

MrExcel MVP
Joined
Jan 15, 2007
Messages
22,776
Like ads on late night TV, automatic default procedures should be taken with a grain of salt.
 

Jonmo1

MrExcel MVP
Joined
Oct 12, 2006
Messages
44,061
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")
 

Forum statistics

Threads
1,081,560
Messages
5,359,608
Members
400,538
Latest member
leon_oscar

Some videos you may like

This Week's Hot Topics

  • VBA (Userform)
    Hi All, I just would like to know why my code isn't working. Here is my VBA code: [CODE=vba]Private Sub OKButton_Click() Dim i As Integer...
  • List box that changes fill color
    Hello, I have gone through so many pages trying to figure this out. I have a 2020 calendar that depending on the day needs to have a certain...
  • Remove duplicates and retain one. Cross-linked cases
    Hi all I ran out of google keywords to use and still couldn't find a reference how to achieve the results of a single count. It would be great if...
  • VBA Copy and Paste With Duplicates
    Hello All, I'm in need of some input. My VBA skills are sub-par at best. I've assembled this code from basic research and it works but is...
  • Macro
    is it possible for a macro to run if the active cell value is different to the value above it
  • IF DATE and TIME
    I currently use this to check if date has passed but i also need to set a time on it too. Is it possible? [CODE=vba]=IF(B:B>TODAY(),"Not...
Top