我想在“ _”之后提取字符串。
这是我的数据:
data
3CC1P01_1 1/2"_ST 25_B31.3
所需的输出应如下所示:
data c1 c2 c3 c4
3CC1P01_1 1/2"_ST 25_B31.3 3CC1P01 1 1/2" ST 25 B31.3
我想在“ _”之后提取字符串。
这是我的数据:
data
3CC1P01_1 1/2"_ST 25_B31.3
所需的输出应如下所示:
data c1 c2 c3 c4
3CC1P01_1 1/2"_ST 25_B31.3 3CC1P01 1 1/2" ST 25 B31.3
字符串操作函数Left,Mid,InStr,InStrRev可以轻松提取C1和C4。其他部分变得复杂。建立一个VBA功能。
Function GetString(strS As String,intP As Integer) As String
Dim strAry As Variant
strAry = Split(strS,"_")
GetString = strAry(intP - 1)
End Function
从查询或文本框中为每个所需部分调用函数。GetString([fieldname],1)