精益求精

时间:2019-05-30 14:11:15

标签: excel vba

简化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

0 个答案:

没有答案