Excel检查由逗号分隔的len字符串

时间:2014-06-10 13:53:59

标签: excel vba excel-vba

我有字符串

15f,158,1669,187,15,156,47t

如何修剪Len<>的所有数据3

所以必须离开

15f,158,187,156,47t

并告诉我删除的内容

1 个答案:

答案 0 :(得分:0)

@David Zemens的想法..这应该有效。经过测试

Sub test()
Dim str As String
Dim s() As String


str = "15f,158,1669,187,15,156,47t"
s = Split(str, ",")


For i = LBound(s) To UBound(s)

If Len(s(i)) = 3 Then

t = IIf(t = "", s(i), t & "," & s(i))

End If

Next i

MsgBox (t)

End Sub