我是VBA的新手,以下是我的代码,但它没有运行,有谁可以帮忙吗?
Dim nPath1() As String
nPath1() = Split(nPath, "\")
'Declare path as integer
Dim path As Integer
'Getting array length
path = UBound(nPath1())
Dim lastname As String
'For Loop
For i = 0 To path-1
lastname += nPath1(i)+"\"
Next i
以上代码无法工作;我的路径字符串是Root\zTrash - No longer needed\NOC\NOC,我想要的是Root\zTrash - No longer needed\NOC。