Thema Datum  Von Nutzer Rating
Antwort
07.05.2024 11:52:21 Surrie
NotSolved
07.05.2024 12:08:21 Mase
NotSolved
07.05.2024 12:29:13 Gast86958
NotSolved
07.05.2024 13:42:26 Surrie
NotSolved
07.05.2024 14:06:34 Mase
NotSolved
Blau Pfad einlesen Excel
07.05.2024 13:18:03 Gast21787
****
Solved
07.05.2024 13:46:00 Gast9686
NotSolved
07.05.2024 14:01:09 Gast31379
NotSolved
07.05.2024 14:14:51 Gast93945
**
NotSolved
07.05.2024 14:48:23 Gast20819
NotSolved
07.05.2024 15:07:57 Gast59678
NotSolved
07.05.2024 15:15:31 Gast10387
NotSolved
07.05.2024 17:16:55 Gast39559
NotSolved
07.05.2024 15:30:32 Surrie
NotSolved
07.05.2024 15:40:36 Gast23659
***
NotSolved
07.05.2024 15:40:47 Surrie
NotSolved
07.05.2024 15:44:00 Gast55468
***
Solved
07.05.2024 15:56:17 Surrie
NotSolved
07.05.2024 16:03:56 Gast62082
NotSolved
07.05.2024 16:24:41 Gast49248
NotSolved
07.05.2024 17:01:11 Gast82588
NotSolved
07.05.2024 17:06:36 Gast35616
**
Solved
07.05.2024 18:08:43 Surrie
NotSolved
08.05.2024 07:47:09 Mase
NotSolved
08.05.2024 22:45:28 Gast9375
NotSolved
09.05.2024 12:23:23 Surrie
NotSolved

Ansicht des Beitrags:
Von:
Gast21787
Datum:
07.05.2024 13:18:03
Views:
172
Rating: Antwort:
 Nein
Thema:
Pfad einlesen Excel

Mit VBA oder mit Excel Power Query.


VBA:

Option Explicit

Private Type FolderInfo
  Id As Long
  Status As String
  FullName As String
End Type

Private Sub GetFolders()
  
  Dim rngFolderIds As Excel.Range
  Dim rngFolderId As Excel.Range
  Dim udtInfo As FolderInfo
  Dim strPath As String
  Dim strResult As String
  
  With Worksheets("Tabelle1") '<< ggf. anpassen
    Set rngFolderIds = .Range("A1", .Cells(.Rows.Count, "A").End(xlUp)) '<< ggf. anpassen
  End With
  
  ' muss mit Backslash '\' enden
  strPath = "C:\Mein Verzeichnis\" '<< anpassen
  
  strResult = Dir$(strPath, vbDirectory)
  Do While strResult <> ""
    
    If strResult = "." Or strResult = ".." Then
      GoTo Continue_Do
    End If
    
    If Not TryParseFolderName(strPath & strResult, udtInfo) Then
      GoTo Continue_Do
    End If
    
    Set rngFolderId = rngFolderIds.Find(udtInfo.Id, , xlValues, xlWhole, xlByColumns, MatchCase:=False)
    If rngFolderId Is Nothing Then
      GoTo Continue_Do
    End If
    
    rngFolderId.Worksheet.Cells(rngFolderId.Row, "E").Value = udtInfo.Status
    
Continue_Do:
    strResult = Dir$()
  Loop
  
End Sub

Private Function TryParseFolderName(Folder As String, ByRef FolderInfo As FolderInfo) As Boolean
  
  Dim fi As FolderInfo
  
  With CreateObject("VBScript.RegExp")
    .Global = False
    .IgnoreCase = True
    .MultiLine = False
    .Pattern = "([^\\_]+?(\d+))_+([^\\_]+)_+(.+)"
    With .Execute(Folder)
      If .Count > 0 Then
        fi.Id = CLng(.Item(0).Submatches(1))
        fi.Status = .Item(0).Submatches(2)
        fi.FullName = .Item(0).Value
        FolderInfo = fi
        TryParseFolderName = True
      End If
    End With
  End With
  
End Function

 

Grüße


Ihre Antwort
  • Bitte beschreiben Sie Ihr Problem möglichst ausführlich. (Wichtige Info z.B.: Office Version, Betriebssystem, Wo genau kommen Sie nicht weiter)
  • Bitte helfen Sie ebenfalls wenn Ihnen geholfen werden konnte und markieren Sie Ihre Anfrage als erledigt (Klick auf Häckchen)
  • Bei Crossposting, entsprechende Links auf andere Forenbeiträge beifügen / nachtragen
  • Codeschnipsel am besten über den Code-Button im Text-Editor einfügen
  • Die Angabe der Emailadresse ist freiwillig und wird nur verwendet, um Sie bei Antworten auf Ihren Beitrag zu benachrichtigen
Thema: Name: Email:



  • Bitte beschreiben Sie Ihr Problem möglichst ausführlich. (Wichtige Info z.B.: Office Version, Betriebssystem, Wo genau kommen Sie nicht weiter)
  • Bitte helfen Sie ebenfalls wenn Ihnen geholfen werden konnte und markieren Sie Ihre Anfrage als erledigt (Klick auf Häckchen)
  • Bei Crossposting, entsprechende Links auf andere Forenbeiträge beifügen / nachtragen
  • Codeschnipsel am besten über den Code-Button im Text-Editor einfügen
  • Die Angabe der Emailadresse ist freiwillig und wird nur verwendet, um Sie bei Antworten auf Ihren Beitrag zu benachrichtigen

Thema Datum  Von Nutzer Rating
Antwort
07.05.2024 11:52:21 Surrie
NotSolved
07.05.2024 12:08:21 Mase
NotSolved
07.05.2024 12:29:13 Gast86958
NotSolved
07.05.2024 13:42:26 Surrie
NotSolved
07.05.2024 14:06:34 Mase
NotSolved
Blau Pfad einlesen Excel
07.05.2024 13:18:03 Gast21787
****
Solved
07.05.2024 13:46:00 Gast9686
NotSolved
07.05.2024 14:01:09 Gast31379
NotSolved
07.05.2024 14:14:51 Gast93945
**
NotSolved
07.05.2024 14:48:23 Gast20819
NotSolved
07.05.2024 15:07:57 Gast59678
NotSolved
07.05.2024 15:15:31 Gast10387
NotSolved
07.05.2024 17:16:55 Gast39559
NotSolved
07.05.2024 15:30:32 Surrie
NotSolved
07.05.2024 15:40:36 Gast23659
***
NotSolved
07.05.2024 15:40:47 Surrie
NotSolved
07.05.2024 15:44:00 Gast55468
***
Solved
07.05.2024 15:56:17 Surrie
NotSolved
07.05.2024 16:03:56 Gast62082
NotSolved
07.05.2024 16:24:41 Gast49248
NotSolved
07.05.2024 17:01:11 Gast82588
NotSolved
07.05.2024 17:06:36 Gast35616
**
Solved
07.05.2024 18:08:43 Surrie
NotSolved
08.05.2024 07:47:09 Mase
NotSolved
08.05.2024 22:45:28 Gast9375
NotSolved
09.05.2024 12:23:23 Surrie
NotSolved