【问题标题】:Find first non-blank value in one column and return said value for all other matching values在一个列中查找第一个非空白值并返回所有其他匹配值的所述值
【发布时间】:2018-02-01 03:28:21
【问题描述】:

我的表中有两列:A 和 B

     A       | B
1    John    | 
2    John    | Yes
3    Paul    |
4    John    |

我想在B 列中输入一个公式,这样如果我要在B2 中输入一个非空白值,它将用相同的值填充A 列中 John 的所有匹配项(即:是)。

好像是VLOOKUP和MATCH的匹配,但我想不通。

【问题讨论】:

    标签: excel match vlookup


    【解决方案1】:

    我想这就是你要找的……

           A      |             B              |   Result
    R1    John    | =IF(A1="John","Yes","No")  |    Yes
    R2    John    | =IF(A2="John","Yes","No")  |    Yes
    R3    Paul    | =IF(A3="John","Yes","No")  |    No
    R4    John    | =IF(A4="John","Yes","No")  |    Yes
    

    (编辑)

    然后您将不得不使用 VBA 事件处理程序。右键单击您的工作表名称,然后单击“查看代码”,然后粘贴以下...

    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    
    If Range("B2").Value = "Yes" Or Range("B2").Value = "yes" Then
    
    Set Rng = Range("B1")
    Rng(1).Value = "Yes"
    Rng(4).Value = "Yes"
    
    End If
    
    End Sub
    

    【讨论】:

    • 没有。我想要的是如果我在 B2 中输入字符串“是”,那么 B1 和 B4 也应该填充“是”
    • 如何将此 VBA 应用于列中的每个字段?
    • 只需添加另一个范围变量:“Rng(RowNumber, ColumnNumber)”
    • 如果有帮助别忘了标记为答案,谢谢。
    猜你喜欢
    • 2018-05-20
    • 1970-01-01
    • 2020-03-21
    • 2017-09-02
    • 1970-01-01
    • 2018-11-02
    • 2019-12-07
    • 2011-01-03
    相关资源
    最近更新 更多