回答
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
這將返回值按您的規範中,只有你沒有指定的是應該如何表現,如果第二個元音是最後一個字母 - 上面只會返回一個空字符串。
下面是我的答案。我還添加了邏輯來檢查是否有第二個元音,如果沒有,則會引發錯誤字符串。細節請參見屏幕截圖。
= IF(A1 <> 「」,IFERROR(MID(A1,FIND( 「|」,SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(LOWER(A1), 「一」, 「|」) , 「E」, 「|」)中, 「i」, 「|」), 「O」, 「|」), 「U」, 「|」),FIND( 「|」,SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE (SUBSTITUTE(LOWER(A1), 「一」, 「|」), 「E」, 「|」)中, 「i」, 「|」), 「O」, 「|」), 「U」,「| 「))+ 1)+1,1),」 無 第二個元音發現 「),」「)
Upvoted。用於刷新的問題[這裏](http://stackoverflow.com/q/36978101/641067) – brettdj
假設你有一個數據建立這樣的,你的短語開始單元格A1並沿着A列向下:
選擇單元格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))
- 1. 如何找到字符串中的第二個元音後的字符
- 2. 如何查找兩個字符串之間的第二個字符串
- 3. 如何查找字符串的倒數第二個字符?
- 4. 查找字符串中字符的第二個索引?
- 5. 如何在PHP中查找字符串的第二個空格?
- 6. 如何找到excel中2個字符串之間的字符
- 7. 查找字符串中的第一個字母和第一個元音java
- 8. 如何在java程序中的字符串中查找元音
- 9. 查找字符串中的最後一個元音
- 10. 在字符串中查找字符串的第一個實例
- 11. 在Java中查找字符串中第二次出現的子字符串
- 12. 查找分隔字符串中的第n個字符串
- 13. 如何找到在C中第一個字符的字符串++
- 14. 根據字符串中的第一個字符查找字符串列表中第一次出現的元素
- 15. 檢查組件中字符串的第二個字符
- 16. javascript:找到字符串內的字符串的第二個最後的外觀?
- 17. 如何查找字符串中元音的數量?
- 18. 如何查找給定字符串中的元音?
- 19. 查找字符串的二維數組中的字符串數
- 20. 查找C字符串中的二維字符數組中的字符串
- 21. 查找多行字符串數組中的第二個單詞
- 22. 如何捕獲字符串中的字符直至第一個元音並從中創建子字符串?
- 23. 查找數組字符串中的第一個字符
- 24. 查找字符串中的第一個非重複字符
- 25. 查找字符串中字符的第一個索引
- 26. 如何查找文本字符串並返回單元格之下的字符串在Excel中
- 27. 查找字符串和追加另一個字符串之後
- 28. 如何在字符串中找到第n個字符?
- 29. 查找字符串中的字符串
- 30. 查找字符串中的字符串
如果你提供的,你已經嘗試做一些例子這將是巨大的,即使其完全錯誤的,因爲它可以幫助人們回答這個問題,並提高你的理解。 – miltonb
在這裏被問到http://stackoverflow.com/q/36978101/641067作爲一個完整的問題。 – brettdj