嗨,请帮我解决以下问题 我需要搜索一个单词" check"从excel中单元格中的文本中,使用VBA将单词紧跟在它旁边 例如,如果我在单元格中有以下文本(1,B) 这是检查流程的样本数据
现在宏应该搜索单词check并给我单词flow作为我的输出。
答案 0 :(得分:0)
Function findWord(rng As Range, criterion As String)
Dim cellContent As String
cellContent = rng.Value
Dim myArray As Variant
myArray = Split(cellContent, " ")
found = False
For Each element In myArray
If found = True Then
findWord = element
Exit For
End If
If element = criterion Then
found = True
End If
Next element
End Function
答案 1 :(得分:0)
你可以使用这个功能
Function GetNextWord(cell As Range, word As String)
Dim words As Variant
words = Split(cell.Text, " ")
Dim index As Variant
index = Application.Match(word, words, 0)
If Not IsError(index) Then If index <= UBound(words) Then GetNextWord = words(index)
End Function