如果来自另一个单元格的值等于来自同一行的特定值,则连接现有单元格

Concatenate existing cells if value from another cell equals a specific value from the same row

我有一个 table 看起来类似于:

A           B
NAME        CONDITION
NAME 1      POOR
NAME 2      GOOD
NAME 3      GOOD
NAME 4      POOR

我想检查 B2 中的所有内容是否为“差”,并在 A2 中的值之前添加一个星号,这是否可能,所以它会像这样更改:

A           B
NAME        CONDITION
*NAME 1     POOR
NAME 2      GOOD
NAME 3      GOOD
*NAME 4     POOR

您想要的更改需要 VBA 宏。您不能通过公式更改同一单元格中的值。试试下面的宏。

Sub AddStar()
Dim cel As Range

    For Each cel In Sheets("Sheet1").Range("A2:A" & Cells(Rows.Count, "A").End(xlUp).Row)
        If cel.Offset(, 1) = "POOR" Then
            cel = "*" & cel
        End If
    Next cel

End Sub