Sub first_folder()
Dim Pfad
Dim APS$: APS = Application.PathSeparator
Pfad = Split(ActiveWorkbook.Path, APS)
MsgBox Pfad(0) & APS & Pfad(1)
End Sub
Function Teil_Pfad$(Ebene&)
'Ebene 0 Laufwerk
'Ebene 1 Hauptordner
'Ebene 2 1. Unterordner, usw.
Dim Pfad, i&
Dim APS$: APS = Application.PathSeparator
Pfad = Split(ActiveWorkbook.Path, APS)
For i = 0 To UBound(Pfad)
Teil_Pfad = Teil_Pfad & Pfad(i) & APS
If i = Ebene Then Exit For
Next
End Function
A | |
1 | I:\aktueller Stand\Spielereien\ |
2 | I:\aktueller Stand\ |
3 | I:\ |
4 | I:\aktueller Stand\Spielereien\ |
Zelle | Formel |
A1 | =Teil_Pfad(2) |
A2 | =Teil_Pfad(1) |
A3 | =Teil_Pfad(0) |
A4 | =Teil_Pfad(3) |