我正在尝试编写一个代码,如果它首先在单元格中不存在,则在前面/中间/结尾添加一行。
该单元格具有原始文本:
T - xxxxx
O - xxxxx
P - xxxxx
在某些单元格中,它没有 T/O/P,因此我需要写:
T - xxxxx
O - None
P - None
有没有办法先检查它是否没有语句,然后在前面/中间/结尾添加行?
For i = 5 To Cells(Rows.Count, "F").End(xlUp).Row
If InStr(Cells(i, "F").Value, "T -") Then
Cells(i, "F").Value = Cells(i, "F").Value
Else
Cells(i, "F").Value = "T - None" & vbCrLf & Cells(i, "F")
End If
If InStr(Cells(i, "F").Value, "O -") Then
Cells(i, "F").Value = Cells(i, "F").Value
Else
Cells(i, "F").Value = Cells(i, "F") & vbCrLf & "O - None"
End If
If InStr(Cells(i, "F").Value, "P -") Then
Cells(i, "F").Value = Cells(i, "F").Value
Else
Cells(i, "F").Value = Cells(i, "F") & vbCrLf & "P - None"
End If
Next i
End Sub
不确定 InStr 是做什么的。