相关疑难解决方法(0)

从VBA中的完整文件名中提取路径

我是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
Run Code Online (Sandbox Code Playgroud)

上面的代码不起作用; 我的路径字符串是Root\zTrash - 不再需要\ NOC\NOC和我想要的是Root\zTrash - 不再需要\ NOC.

excel vba excel-vba

6
推荐指数
1
解决办法
6453
查看次数

标签 统计

excel ×1

excel-vba ×1

vba ×1