Removing vowels from words...

  • Thread starter Thread starter gibertini
  • Start date Start date
G

gibertini

How to remove vowels from words? Fpr example, in one row we have
google, excell, macro,... and the result in another row is ggl, xcll,
mcr,... Thanks.
 
Maybe this function can help you:

'------------------------------------------------------
Function removeVowel(VowelWord As String) As String

Dim NoVowelWord As String

For L = Len(VowelWord) To 1 Step -1
If Mid(VowelWord, L, 1) = "a" Or _
Mid(VowelWord, L, 1) = "e" Or _
Mid(VowelWord, L, 1) = "i" Or _
Mid(VowelWord, L, 1) = "o" Or _
Mid(VowelWord, L, 1) = "u" Then
Else
NoVowelWord = Mid(VowelWord, L, 1) & NoVowelWord
End If
Next L

removeVowel = NoVowelWord

End Function
'------------------------------------------------------

It returns the word without vowels

Cheers Carlo
 
Maybe this function can help you:

'------------------------------------------------------
Function removeVowel(VowelWord As String) As String

Dim NoVowelWord As String

For L = Len(VowelWord) To 1 Step -1
If Mid(VowelWord, L, 1) = "a" Or _
Mid(VowelWord, L, 1) = "e" Or _
Mid(VowelWord, L, 1) = "i" Or _
Mid(VowelWord, L, 1) = "o" Or _
Mid(VowelWord, L, 1) = "u" Then
Else
NoVowelWord = Mid(VowelWord, L, 1) & NoVowelWord
End If
Next L

removeVowel = NoVowelWord

End Function
'------------------------------------------------------

It returns the word without vowels

Cheers Carlo


Why is the loop stepping backwards?
 
no VBA

=SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A1,"a",""),"e",""),"I",""),"o",""),"u","")

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)
 
If he didn't go backwards, that code would reverse the text, so you would
get __rcm ,llx ,lgg__ instead of __ggl, xcll, mcr__

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)
 
If he didn't go backwards, that code would reverse the text, so you would
get __rcm ,llx ,lgg__ instead of __ggl, xcll, mcr__

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

Only because he is appending to the output string backwards too. Just
seems a bit odd.
 
Just to add to Bob's formula.

=substitute() is case sensitive (and I bet autocorrect changed his i to I <bg>).

Another alternative:

=SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(LOWER(A1),
"a",""),"e",""),"i",""),"o",""),"u","")
 
Hi Guys,

just to add a comment to my code in regards to backstepping.
I first had a total different approach, which was total crap, that's
where the backward steps are coming from. Obviously it works as well
if you go the other way around, didn't realize that though until I saw
your post :)

Here's the forward version, although the other one should work fine:

'------------------------------------------------------
Function removeVowel(VowelWord As String) As String

Dim NoVowelWord As String

For L = 1 to Len(VowelWord)
If Mid(VowelWord, L, 1) = "a" Or _
Mid(VowelWord, L, 1) = "e" Or _
Mid(VowelWord, L, 1) = "i" Or _
Mid(VowelWord, L, 1) = "o" Or _
Mid(VowelWord, L, 1) = "u" Then
Else
NoVowelWord = NoVowelWord & Mid(VowelWord, L, 1)
End If
Next L

removeVowel = NoVowelWord

End Function
'------------------------------------------------------

cheers carlo
 
How to remove vowels from words? Fpr example, in one row we have
google, excell, macro,... and the result in another row is ggl, xcll,
mcr,... Thanks.


Here's a UDF:

==============================
Option Explicit
Function NV(str As String) As String
Dim re As Object
Set re = CreateObject("vbscript.regexp")
re.IgnoreCase = True
re.Global = True
re.Pattern = "[aeiou]"
NV = re.Replace(str, "")
End Function
==============================
--ron
 
Hi Guys,

just to add a comment to my code in regards to backstepping.
I first had a total different approach, which was total crap, that's
where the backward steps are coming from. Obviously it works as well
if you go the other way around, didn't realize that though until I saw
your post :)

Here's the forward version, although the other one should work fine:

'------------------------------------------------------
Function removeVowel(VowelWord As String) As String

Dim NoVowelWord As String

For L = 1 to Len(VowelWord)
If Mid(VowelWord, L, 1) = "a" Or _
Mid(VowelWord, L, 1) = "e" Or _
Mid(VowelWord, L, 1) = "i" Or _
Mid(VowelWord, L, 1) = "o" Or _
Mid(VowelWord, L, 1) = "u" Then
Else
NoVowelWord = NoVowelWord & Mid(VowelWord, L, 1)
End If
Next L

removeVowel = NoVowelWord

End Function
'------------------------------------------------------

cheers carlo

This is fun, just seeing everyone's personal approach to this macro,.
Mine would be;


Public Function novowels(ByVal txt As String)

If txt = "" Then Exit Function

For l = 1 To Len(txt)
Select Case LCase(Mid(txt, l, 1))

Case "a", "e", "i", "o", "u"

Case Else
novowels = novowels & Mid(txt, l, 1)
End Select

Next l


End Function
 
There was no i in the example <g>

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)
 
That sounds like a sign in every lockerroom I've ever seen:

There is no I in TEAM.

(But there is a ME, but it's out of order <vbg>.)

Bob said:
There was no i in the example <g>
<<snipped>>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top