简化Excel VBA代码帮助 冗长的代码和混乱为我简化了
Sub AppendToExistingOnRight()
Range("A1").Select
For Each c In Selection
If IsEmpty(ActiveCell.Value) Then
c.Value = "State: " & c.Value & Range("P7")
ElseIf InStr(c.Value, c.Value = "State: " & c.Value & Range("P7")) < 1 Then c.Value = Delete
c.Value = "State: " & c.Value & Range("P7")
ElseIf c.Value <> "" Then c.Value = c.Value & Range("P7")
End If
Next
End Sub