如果单词不是stringreplace
我无法创build一个VBA来replace列中的一些值。
标准:
我有一个string中的2个字。 如果这两个单词不在列中,则用variablesreplace单元格。
例:
day day day free day Busy day Busy
string:(一天,免费)
如果一个字不包含在String中,则用“off”
结论:
Day Day Day Free Day Off Day Off
让我们来帮助他哈哈
Sub DateSelectandClean() Dim str, iRow, iCol str = "day, free" iRow = 1 iCol = 1 Do If (Cells(iRow, iCol).Value <> "") Then If (InStr(1, str, Cells(iRow, iCol).Value) = 0) Then Cells(iRow, iCol).Value = "off" End If iRow = iRow + 1 Else Exit Do End If Loop End Sub
鉴于A列包含:
day day day free day Busy day Busy
输出将是:
day day day free day off day off