简体   繁体   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

My excel file will have two sheets Sheet-1: working sheet我的 excel 文件将有两张表 Sheet-1: working sheet

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

Compare the two phrases and based on the keyword list in next sheet, add keyword in Column"A".比较这两个短语并根据下一张表中的关键字列表,在“A”列中添加关键字。

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

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

For k = 9 To lastrowtofind对于 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

Next k下一个 k

End Sub结束子

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 将数据从Word复制到Excel单元格。 然后在相邻单元格中触发公式。 怎么样? - Copy data from Word to Excel Cell. Then trigger formula in adjacent cell. How? EXCEL:检查是否在另一列中找到单元格文本 - EXCEL: Check if cell text is found in another column 如果单元格包含WORD,然后将WORD提取到另一个单元格-Excel / VBA - IF cell contains WORD then extract WORD into another cell - Excel/VBA Excel:在单元格中找到一个单词,然后返回前一个单词和找到的单词 - Excel: find a word in a cell, then return the preceding word and the found word 如果Excel中包含的单词位于另一列中,如何在Excel中突出显示单元格 - How to highlight a cell in Excel if the word it contains is in another column 换行单元格文本而不将任何单词字符分成两行 - Wrap cell text without dividing any word characters into two lines 定义检查同一单元格中的两个日期以及其他单元格中的文本的行颜色。 Excel宏? - Define color of row checking two dates within same cell and text in other cell. Excel macros? 如何检查 excel 单元格是否包含单词 - How to check if a excel cell contains a word 如何在Excel中的单元格中添加特定单词? - How to Add Specific word in a cell in Excel? VBA可以将一个单元格中的单词逐字匹配到另一个单元格中的单词 - VBA to Match word by word from a cell to word by word in an another cell
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM