Split function compare options

JenniferMurphy

Well-known Member
Joined
Jul 23, 2011
Messages
2,532
Office Version
  1. 365
Platform
  1. Windows
I'm a bit puzzled by a couple of the Compare options for the Split function.

According to this link:

https://msdn.microsoft.com/en-us/vba/language-reference-vba/articles/split-function

The Compare option has these values:

Value
Variable
Description
-1vbUseCompareOptionPerforms a comparison using the setting of the Option Compare statement.
0vbBinaryComparePerforms a binary comparison. Case sensitive? Default?
1vbTextComparePerforms a textual comparison. Case insensitive?
2vbDatabaseCompareMicrosoft Access only. Performs a comparison based on information in your database.

<tbody>
</tbody>

I tested these Compare settings using this expression:
Code:
A=Split("3.5ft","FT",,see table)

I got these results:
Compare SettingUBoundA(0)A(1)Comments
omitted0|3.5ft|Case sensitive?
-1----Invalid call
vbUseCompareOption0|3.5ft|Case sensitive?
00|3.5ft|Case sensitive?
vbBinaryCompare0|3.5ft|Case sensitive?
11|3.5|||Case insensitive?
vbTextCompare1|3.5|||Case insensitive?
21|3.5|||Case insensitive?
vbDatabaseCompare1|3.5|||Case insensitive?
31|3.5|||Case insensitive?

<tbody>
</tbody>

Questions:


  1. Which one is the default? It appears to be the binary compare (1).
  2. Why do I get an error when I explicitly code "-1", but not when I code vbUseCompareOption, which = -1?
  3. Is the binary compare case sensitive and the text compare case insensitive?
  4. It appears that any value > 1 works the same as 1.
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
I found the answer to #2 . The website is wrong. the value of vbUseCompareOption is null, not -1.
 
Upvote 0
The default is vbBinaryCompare. This is shown in the function arguments when you type "Split(".

vbBinaryCompare is case sensitive and vbTextCompare is case insensitive.

The same rules apply to other string functions such as Instr and Replace.
 
Upvote 0
The default is vbBinaryCompare. This is shown in the function arguments when you type "Split(".
Ah, good point.

vbBinaryCompare is case sensitive and vbTextCompare is case insensitive.

The same rules apply to other string functions such as Instr and Replace.

Thanks
 
Upvote 0
The default is vbBinaryCompare. This is shown in the function arguments when you type "Split(".
It appears that this method, like the help files, is not perfect. At least on my VB6 system, the argument prompt does not show any default value for the second argument (the delimiter). The default is the space character.

I would think that as long as M$FT has been in business and as much money they have made off of everyone, they could at least fix some of the most obvious and simplest bugs.
 
Upvote 0
At least on my VB6 system, the argument prompt does not show any default value for the second argument (the delimiter). The default is the space character.

I would think that as long as M$FT has been in business and as much money they have made off of everyone, they could at least fix some of the most obvious and simplest bugs.
It is covered in the Help file for the Split function.
 
Upvote 0
It is covered in the Help file for the Split function.

Yes. My point was that some of the defaults are covered in the help file and some in the argument prompt but neither source covers them all. Pretty typical for M$FT.
 
Upvote 0

Forum statistics

Threads
1,214,982
Messages
6,122,580
Members
449,089
Latest member
Motoracer88

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