Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default binary sort?

Hello!

In VBA I can set an option compare to binary in order to compare strings
case sensitive. With that option set, "a" and "A" are treated as different
values ("A" < "a")
But if I use the sort method with MatchCase:=True the sort order is "a" <
"A" !

What I need is compare mode and sort mode to behave according to the same
order of characters/strings.

Is there a way around this? Can I sort binary? Or am I missing something else?

Any help is appreciated

Herbert Becker,
Austria
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,071
Default binary sort?

When you set Option Compare... you are telling VBA to do something.
When you use the Sort method of the Range object, you are asking XL to
do something. While one might argue that your VBA setting should apply
to XL the reality is that they don't and it is up to you to ensure that
the two behave the way you want them to.

Also, you might want to check the documentation of the Sort method's
MatchCase argument. To me it seems counter-intuitive: "MatchCase
Optional Variant. True to do a case-sensitive sort; False to do a sort
that=3Fs not case sensitive."

--
Regards,

Tushar Mehta
www.tushar-mehta.com
Excel, PowerPoint, and VBA add-ins, tutorials
Custom MS Office productivity solutions

In article ,
says...
Hello!

In VBA I can set an option compare to binary in order to compare strings
case sensitive. With that option set, "a" and "A" are treated as different
values ("A" < "a")
But if I use the sort method with MatchCase:=True the sort order is "a" <
"A" !

What I need is compare mode and sort mode to behave according to the same
order of characters/strings.

Is there a way around this? Can I sort binary? Or am I missing something else?

Any help is appreciated

Herbert Becker,
Austria

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default binary sort?

Hello Tushar,

first of all, thank you for your reply.

You are right, the compare option concerns the VBA interpreter and the sort
method is used on a Excel object. But both are based on two different "ideas
of how to compare" strings. That might be a fact, but it's still annoying
that there is no way I can make these two behave identically.

According to Excel Help the option MatchCase is a variant. And yet it can
only be True or False.

Unless someone else has has an idea I will have to come up with a costly
workaround ...

Thanks again,
Herbert

"Tushar Mehta" wrote:

When you set Option Compare... you are telling VBA to do something.
When you use the Sort method of the Range object, you are asking XL to
do something. While one might argue that your VBA setting should apply
to XL the reality is that they don't and it is up to you to ensure that
the two behave the way you want them to.

Also, you might want to check the documentation of the Sort method's
MatchCase argument. To me it seems counter-intuitive: "MatchCase
Optional Variant. True to do a case-sensitive sort; False to do a sort
that=3Fs not case sensitive."

--
Regards,

Tushar Mehta
www.tushar-mehta.com
Excel, PowerPoint, and VBA add-ins, tutorials
Custom MS Office productivity solutions

In article ,
says...
Hello!

In VBA I can set an option compare to binary in order to compare strings
case sensitive. With that option set, "a" and "A" are treated as different
values ("A" < "a")
But if I use the sort method with MatchCase:=True the sort order is "a" <
"A" !

What I need is compare mode and sort mode to behave according to the same
order of characters/strings.

Is there a way around this? Can I sort binary? Or am I missing something else?

Any help is appreciated

Herbert Becker,
Austria


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Binary NOT? Mark Scott[_3_] Excel Worksheet Functions 4 January 24th 10 09:21 PM
binary format John Excel Discussion (Misc queries) 2 April 26th 08 01:09 AM
Hexadecimal to binary [email protected] Excel Discussion (Misc queries) 5 March 4th 06 05:45 PM
Solver returns non binary answer in binary constrained cells Navy Student Excel Worksheet Functions 6 September 1st 05 03:11 PM
Binary operations (left/right shift, binary and/or, etc.) Mike Hodgson Excel Programming 4 June 17th 05 09:27 AM


All times are GMT +1. The time now is 09:43 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"