如果'列大小'是列A,數據從第2行開始,則運行此例程。
Sub del_Out_of_Stock()
Dim rw As Long, str As String, str2 As String, v As Long, vSZs As Variant
str = "(out of stock)"
With Worksheets("Sheet1")
For rw = 2 To .Cells(Rows.Count, 1).End(xlUp).Row
With .Cells(rw, 1)
vSZs = Split(.Value2, Chr(59))
For v = LBound(vSZs) To UBound(vSZs)
If CBool(InStr(1, vSZs(v), str, vbTextCompare)) Then _
vSZs(v) = vbNullString
Next v
str2 = Join(vSZs, Chr(59))
Do While CBool(InStr(1, str2, Chr(59) & Chr(59))): str2 = Replace(str2, Chr(59) & Chr(59), Chr(59)): Loop
.Value = str2
End With
Next rw
End With
End Sub
您可能需要a)更改工作表名稱,b)更改列索引號並可能c)更改起始行。
非常感謝!所以我想只有通配符纔有可能。 –