我需要在整个工作表中搜索某个单词并填充一列(在这种情况下为B),其中包含A列中没有该特定单词的相同单词(在本例中为单词Photo
)。例如:
A B
1 Photo Leon | Leon
2 Video Raul | Kelie
3 Broadcast Noa |
4 Photo Kelie |
5 Video Carl |
6 Broadcast Eitan |
有人可以帮忙吗?
答案 0 :(得分:0)
试试这个相当小的宏:
Sub FindPhoto()
Dim N As Long, i As Long
Dim ary, K As Long
N = Cells(Rows.Count, "A").End(xlUp).Row
K = 1
For i = 1 To N
v = Cells(i, "A").Text
If InStr(v, "Photo") > 0 Then
ary = Split(v, " ")
Cells(K, "B").Value = Trim(ary(1))
K = K + 1
End If
Next i
End Sub
答案 1 :(得分:0)
请尝试(调整A$1:A$100
以适应):
=SUBSTITUTE(IFERROR(INDEX(A$1:A$100,SMALL(IF(LEFT(A$1:A$100,6)="Photo ",ROW(A$1:A$100)),ROW(B1))),""),"Photo ","")
使用Ctrl + Shift + Enter输入并向下复制,直到出现第一个空白单元格。
您可能希望用参数替换Photo
。假设在D1中输入Photo
,而不是:
=SUBSTITUTE(IFERROR(INDEX(A$1:A$100,SMALL(IF(LEFT(A$1:A$100,LEN(D$1))=D$1,ROW(A$1:A$100)),ROW(B1))),""),D$1,"")