考虑一个字符串是否有多个逗号(,)我想获得excel VBA宏中每个逗号之前存在的3个字符。例如在字符串" AR6,AB4,UUF,ABG,UUG,AC4,ABF,"在这个字符串中我想首先获得AR6的值然后打印然后第二个AB4,依此类推。该字符串可能包含n个逗号。能帮我解决这个问题。
答案 0 :(得分:0)
试试这个:
Sub test()
Dim st As String
Dim a As Variant
st = "AR6, AB4, UUF, ABGtt, UUGyy, AC4, ABF,"
a = Split(st, ",")
For i = 0 To UBound(a)
Debug.Print Left(Trim(a(i)), 3)
Next
End Sub