如果列B中的值为特定文本,请将特定文本插入列A中的值 [英] If values in Column B = specific text, insert specific text into a value in Column A

查看:91
本文介绍了如果列B中的值为特定文本,请将特定文本插入列A中的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

简单地说 - 如果列B中的任何单元格包含 thisvalue 然后附加到列A中的相邻单元格, sometext

Simply - if any cell in Column B contains thisvalue then append to the adjoining cell in Column A with sometext.

如何完成?

推荐答案


将此公式放在A1中,然后根据需要下拉:

Put this formula in A1, then drag down as necessary:

=IF(B1="thisvalue","sometext","")

编辑

使用Visual Basic编辑器,您可以更新单元格A的内容,如下所示:

Using a the Visual Basic Editor, you can update the contents of cell A like this:

Private Sub UpdateColumnA()
    Dim x As Long
    For x = 1 To 65536
        If InStr(1, Sheet1.Range("$B$" & x), "thisvalue") > 0 Then
            Sheet1.Range("$A$" & x) = Sheet1.Range("$A$" & x) & "sometext"
        End If
    Next
End Sub

重复但是,宏的运行会再次附加文本;如果您不希望这样做,您将需要更多验证码。

Repeated runnings of the macro, however, will append the text again; you'll need more validation code if you don't want this to happen.

这篇关于如果列B中的值为特定文本,请将特定文本插入列A中的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆