=LEN(MID(B4,SEARCH("Data\",B4)+4,255))-LEN(SUBSTITUTE(MID(B4,SEARCH("Data\",B4)+4,255),"\",""))-(D4="File")
Function Check_SubFolder(iLink As String, iFolder As String) As Long
Dim temp As Variant
Dim i As Integer
temp = Split(iLink, "\")
For i = LBound(temp) To UBound(temp)
If temp(i) = "Data" And iFolder = "Folder" Then
Check_SubFolder = UBound(temp) - i
Exit For
ElseIf temp(i) = "Data" And iFolder <> "Folder" Then
Check_SubFolder = UBound(temp) - i - 1
Exit For
End If
Next i
End Function