2016-04-28 10 views
1

私の文字列が出力さEXCELの文字列の2番目の母音の後の文字を見つける方法は?例えば

Pでなければなりません

ハッピーソング

ある場合。

それが空白の場合は、

+0

あなたはあなたがしようとしているもののいくつかの例を提供する場合、それは素晴らしいことだ、でもそれは、人々が質問に答えると、あなたの理解を高めるのに役立ちますように、その完全に間違っている場合。 – miltonb

+1

詳細については、http://stackoverflow.com/q/36978101/641067を参照してください。 – brettdj

答えて

0

を "何" を表示しないこれは、第二の母​​音の後に手紙を見つける:(コメント付き)

=IF(A1<>"",MID(A1,FIND("}}}",SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(LOWER(A1),"a","}"),"e","}"),"i","}"),"o","}"),"u","}"),"y","}"),"}","}}}",2))+1,1),"") 

![enter image description here

0

VBAの答えがあります;

Function AfterSecondVowel(InputRange As String) 

'Put all the ascii codes for vowels (upper and lower case) in an array 
asciicodesforvowels = Array(65, 97, 69, 101, 73, 105, 79, 111, 85, 117) 
Dim Counter As Integer 
Dim i As Integer 

Counter = 0 

'Loop through all the letters in the input string 
For i = 1 To Len(InputRange) 

'Check to see if trying to match the current letter (converted to an ascii code) you are on from the input range 
'is in the array of ascii codes - If it isn't this will throw an error 
If Not IsError(Application.Match(Asc(Mid(InputRange, i, 1)), asciicodesforvowels, False)) Then 

'Increment your counter by 1 
Counter = Counter + 1 

End If 

'Check to see if the counter has reached 2 yet - You can change the = 2 bit here to any number you want to return 
'the letter after the N'th vowel 
If Counter = 2 Then 
'If it has reached the second vowel, skip to the next letter 
i = i + 1 
'Set the output of the function to this letter you've moved to 
AfterSecondVowel = Mid(InputRange, i, 1) 
'Exit the function 
Exit Function 

End If 
'Otherwise loop through to the next letter 
Next i 

'If you reach the end of the letters without exiting the function it's because there weren't 
'two vowels so exit the function returning the string value 'Nothing' 

AfterSecondVowel = "Nothing" 

End Function 

これはあなたの仕様に従って値を返します、あなたが指定していない唯一のことは、第二母音が最後の文字であれば、それはどのように振る舞うべきかである - 上記は、単に空の文字列を返します。

2

以下は私の答えです。私は、2番目の母音があるかどうかをチェックするロジックを追加しました。もしそれがなければ、エラー文字列をスローします。詳細はスクリーンショットを参照してください。

= IF(A1 <> ""、IFERROR(MID(A1、(FIND "|"、SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(LOWER(A1)、 "A"、 "|") ( "|"、 "e"、 "|")、 "i"、 "|")、 "o"、 "|")、 "u"、 "|")、FIND( "|"、SUBSTITUTE(SUBSTITUTE(SUBSTITUTE ( "a"、 "|")、 "e"、 "|")、 "i"、 "|")、 "o"、 "|")、 "u"、 "|" "))+ 1)+1,1)、" 何 二母音が見つかりませんでした ")、" ")

あなたのフレーズが、セルA1を開始すると、このようなデータを設定していると仮定し

enter image description here

+0

Upvoted。リフレッシュされた質問[ここ]で使用される(http://stackoverflow.com/q/36978101/641067) – brettdj

0

コラムA:

tigeravatar example for Deeksha Jha

セルB1と、そのセルが選択されてを選択し、名前付き範囲を作成します。私はLetterAfterVowel2それを命名し、それは、この式で定義されています

=MID($A1,MIN(SEARCH({"a","e","i","o","u","y"},$A1&"aieouy",MIN(SEARCH({"a","e","i","o","u","y"},$A1&"aieouy"))+1))+1,1) 

今、私たちはその混乱に一つ一つの時間を入力する必要はありません、それは完成式がはるかにきれいになります。ダウンコピーされたセルB1とでは、この式である:

=IF(A1="","",IF(LetterAfterVowel2=" ","Nothing",LetterAfterVowel2)) 
関連する問題