我正在尝试在“ material_cd”单词处拆分此字符串,并使用拆分后的字符串创建新行。
material_cd = 10798259 AND inputportcount 24 material_cd = 10798259 AND outputportcount 144 material_cd = 10798259 AND inputblockcount 1 material_cd = 10798259 AND outputblockcount 1 material_cd = 10798259 AND bv_type_name FDH material_cd = 10798259 AND manufacturer Corning material_cd = 10798259 AND partnumber N/A material_cd = 10798259 AND bv_status Preliminary Designed material CD = 10798259 AND bv_tail_length 25
所需结果:
material_cd = 10798259 AND inputportcount <> 24
material_cd = 10798259 AND outputportcount <> 144
material_cd = 10798259 AND inputblockcount <> 1
material_cd = 10798259 AND outputportcount <> 1
....依此类推
这可能吗?
答案 0 :(得分:2)
这样的事情,
Sub tt()
Dim s As String
Dim a() As String
s = "material_cd = 10798259 AND inputportcount 24 material_cd = 10798259 AND outputportcount 144 material_cd = 10798259 AND inputblockcount 1 material_cd = 10798259 AND outputblockcount 1 material_cd = 10798259 AND bv_type_name FDH material_cd = 10798259 AND manufacturer Corning material_cd = 10798259 AND partnumber N/A material_cd = 10798259 AND bv_status Preliminary Designed material CD = 10798259 AND bv_tail_length 25"
s = Replace(s, "material_cd", "*^*material_cd")
a = Split(s, "*^*")
Range("a1").Resize(UBound(a) - 1, 1).Value = Application.Transpose(a)
End Sub
答案 1 :(得分:0)
只需使用split
命令并使用字符串material_cd
作为拆分条件。处理分割的部分时,再次添加字符串material_cd
:
Const s = "material_cd = 10798259 AND inputportcount 24 ..."
Const splitString = "material_cd"
Dim a() As String, i As Integer
a = Split(s, splitString )
For i = 0 To UBound(a)
Debug.Print splitString & a(i)
Next i