Re: How do I copy first consonant from a word into new cell
- From: "Rick Rothstein" <rick.newsNO.SPAM@xxxxxxxxxxxxxxxxxx>
- Date: Sun, 12 Jul 2009 14:21:47 -0400
Instead of using Option Compare Text to make your Like comparison case
insensitive, you could remove it and use this Like comparison instead...
If Not sTemp Like "[AEIOUYaeiouy]" Then
and instead of using the Not keyword, I would probably have used the Like
operator's negation meta-character (which is the exclamation mark)...
If sTemp Like "[!AEIOUYaeiouy]" Then
Of course, another way to do this would be to remove the Option Compare Text
statement and use this statement to assign the values to sTemp...
sTemp = LCase(Mid(str, i, 1))
Then you can leave the rest of your code exactly as you posted it and it
will work correctly.
Yes, there are many different ways to solve this problem.
Yes, I know you knew that... I just thought the readers of this thread might find it interesting to see some of them.
Some even include the Regular Expressions you seem to
dislike -- but I posted one subsequently :-)
I don't dislike Regular Expressions (really, I don't), it is just that I feel most people posting questions here are not all that familiar with them and would be more comfortable with solutions coded using native VB functions, operators, etc. I do feel your posting Regular Expression solutions is important, though, both for those reading this thread now, and those reading the thread later on in the archives, who are familiar with them.
--
Rick (MVP - Excel)
.
- Follow-Ups:
- Re: How do I copy first consonant from a word into new cell
- From: Ron Rosenfeld
- Re: How do I copy first consonant from a word into new cell
- References:
- How do I copy first consonant from a word into new cell
- From: ozmann08
- Re: How do I copy first consonant from a word into new cell
- From: Ron Rosenfeld
- Re: How do I copy first consonant from a word into new cell
- From: Rick Rothstein
- Re: How do I copy first consonant from a word into new cell
- From: Ron Rosenfeld
- How do I copy first consonant from a word into new cell
- Prev by Date: Re: How do I copy first consonant from a word into new cell
- Next by Date: excel weekday function
- Previous by thread: Re: How do I copy first consonant from a word into new cell
- Next by thread: Re: How do I copy first consonant from a word into new cell
- Index(es):
Relevant Pages
|