簡體   English   中英

在 Excel 檢查兩個單元格中的短語,如果在兩個單元格中找到任何列出的單詞,則需要在另一個單元格中添加該單詞。 對整列重復此操作

[英]In Excel Check phrases in two cell and in the two cell if any listed word found,need to add the word in another cell. repeat this for entire column

我的 excel 文件將有兩張表 Sheet-1: working sheet

Column-A : Keyword to be added from macro
Column-B : phrase=1
Column-C : Phrase=2

比較這兩個短語並根據下一張表中的關鍵字列表,在“A”列中添加關鍵字。

Sub Macro5() ' ' 1 Number ' Dim lastrowtofind As Long Range("A8").Activate ActiveCell.FormulaR1C1 = "PFP 前五個描述"

lastrowtofind = Sheets(3).Range("A30000").End(xlUp).Row

對於 k = 9 到 lastrowtofind

tofind = Sheets(3).Range("AZ" & k).Value

'Broken-->BROK
If tofind = Empty Then
Else
    If Sheets(3).Range("AX" & k) = Empty Then
    Set rgFound = Sheets(3).Range("AZ" & k).Find("Brok", LookIn:=xlValues)
    If rgFound Is Nothing Then
    Else
    Sheets(3).Range("AX" & k).Value = "BROKEN"
    End If
    End If
End If



'BURNED-->BULB
If tofind = Empty Then
Else
    If Sheets(3).Range("AX" & k) = Empty Then
    Set rgFound = Sheets(3).Range("AZ" & k).Find("BULB", LookIn:=xlValues)
    If rgFound Is Nothing Then
    Else
    Sheets(3).Range("AX" & k).Value = "BURNED"
    End If
    End If
End If

下一個 k

結束子

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM