Thema Datum  Von Nutzer Rating
Antwort
05.01.2016 07:03:28 Andre
NotSolved
06.01.2016 15:27:50 Gast28524
NotSolved
06.01.2016 15:40:24 Andre
NotSolved
06.01.2016 16:20:53 Gast25935
NotSolved
07.01.2016 07:56:43 Andre
NotSolved
06.01.2016 22:17:39 Gast69812
NotSolved
07.01.2016 05:51:07 Gast10186
NotSolved
07.01.2016 07:45:58 Andre
NotSolved
07.01.2016 08:06:27 Andre
NotSolved
09.01.2016 19:10:40 Gast62795
NotSolved
11.01.2016 08:20:07 Andre
NotSolved
11.01.2016 10:22:55 Gast7783
NotSolved
11.01.2016 12:36:32 Andre
NotSolved
11.01.2016 12:39:35 Andre
NotSolved
11.01.2016 15:56:45 Gast87431
NotSolved
11.01.2016 16:14:03 Andre
NotSolved
11.01.2016 16:30:15 Gast67223
NotSolved
12.01.2016 08:21:54 Gast77619
NotSolved
11.01.2016 16:34:42 Gast89738
NotSolved
12.01.2016 08:27:34 Andre
NotSolved
12.01.2016 12:41:22 Gast14356
NotSolved
12.01.2016 14:12:59 Andre
NotSolved
12.01.2016 14:17:04 Andre
NotSolved
12.01.2016 15:46:33 Gast57141
NotSolved
13.01.2016 07:56:18 Andre
NotSolved
13.01.2016 08:09:51 Andre
NotSolved
13.01.2016 08:32:16 Gast86894
NotSolved
13.01.2016 08:42:11 Andre
NotSolved
13.01.2016 19:20:12 Gast86704
NotSolved
14.01.2016 08:32:14 Andre
NotSolved
14.01.2016 10:10:53 Gast34177
NotSolved
14.01.2016 10:28:38 Andre
NotSolved
14.01.2016 10:45:46 Gast25298
NotSolved
14.01.2016 10:58:07 Andre
NotSolved
14.01.2016 11:33:50 Gast21502
NotSolved
14.01.2016 12:18:11 Andre
NotSolved
14.01.2016 15:49:42 Gast23760
NotSolved
14.01.2016 16:09:09 Andre
****
NotSolved
14.01.2016 18:55:41 Gast81853
NotSolved
15.01.2016 08:18:04 Andre
NotSolved
15.01.2016 19:30:59 Gast45694
NotSolved
18.01.2016 08:09:01 Andre
NotSolved
18.01.2016 08:12:08 Andre
NotSolved
18.01.2016 18:02:48 Gast82440
NotSolved
19.01.2016 08:40:26 Andre
NotSolved
19.01.2016 13:36:07 Gast75130
NotSolved
19.01.2016 14:04:24 Andre
NotSolved
19.01.2016 18:19:20 Gast65228
NotSolved
19.01.2016 18:20:55 Gast29977
NotSolved
20.01.2016 07:21:35 Andre
NotSolved
20.01.2016 11:42:16 aufran
NotSolved
20.01.2016 11:54:57 Andre
NotSolved
20.01.2016 12:03:47 Gast44577
NotSolved
20.01.2016 15:58:00 aufran
NotSolved
21.01.2016 21:41:23 aufran
NotSolved
21.01.2016 21:52:00 Gast14641
NotSolved
20.01.2016 12:01:05 Gast18965
NotSolved
20.01.2016 12:07:06 Gast343
NotSolved
20.01.2016 12:18:06 Andre
NotSolved
20.01.2016 12:28:46 Gast95544
Solved
20.01.2016 20:02:43 Gast15375
NotSolved
21.01.2016 07:52:14 Andre
NotSolved
21.01.2016 10:46:39 Gast54269
NotSolved
21.01.2016 10:59:39 Gast19460
NotSolved
21.01.2016 15:04:13 Andre
NotSolved
21.01.2016 15:09:07 Andre
NotSolved
21.01.2016 15:55:44 Gast30371
NotSolved
25.01.2016 07:53:22 Andre
NotSolved
25.01.2016 08:35:01 Andre
NotSolved
25.01.2016 08:35:07 Andre
NotSolved
22.01.2016 13:51:05 Gast11423
NotSolved
22.01.2016 22:45:16 aufran
NotSolved
25.01.2016 08:08:43 Andre
NotSolved
25.01.2016 11:18:33 aufran
NotSolved
25.01.2016 12:07:03 Andre
NotSolved
25.01.2016 08:06:16 Andre
NotSolved
25.01.2016 19:38:52 Gast92881
NotSolved
25.01.2016 19:40:23 Gast31903
NotSolved
26.01.2016 07:26:40 Andre
NotSolved
26.01.2016 09:25:34 Gast31028
NotSolved
26.01.2016 10:15:47 Andre
NotSolved
26.01.2016 11:48:57 Gast10723
NotSolved
26.01.2016 13:23:31 Andre
NotSolved
Blau Durchsuchen von bestimmten Exceldateien mit Hilfe von einem Makro Exce
27.01.2016 14:23:48 Gast20611
NotSolved
27.01.2016 14:48:05 Andre
NotSolved
27.01.2016 14:56:24 Andre
NotSolved
27.01.2016 15:30:27 Gast76603
NotSolved
27.01.2016 15:30:28 Gast42470
NotSolved
27.01.2016 15:57:14 Andre
NotSolved
27.01.2016 16:21:33 Andre
NotSolved
27.01.2016 20:54:35 Gast808
NotSolved
28.01.2016 07:25:57 Andre
NotSolved
28.01.2016 16:20:47 Gast66068
Solved
29.01.2016 12:28:40 Andre
NotSolved
29.01.2016 17:35:37 Gast3880
NotSolved
30.01.2016 10:06:13 aufran
NotSolved

Ansicht des Beitrags:
Von:
Gast20611
Datum:
27.01.2016 14:23:48
Views:
692
Rating: Antwort:
  Ja
Thema:
Durchsuchen von bestimmten Exceldateien mit Hilfe von einem Makro Exce

Hallo Andre! Also einen Versuch haben wir noch. :-) Inspiriert von aufran habe ich mal die andere Methode in meinen Code integriert. Ist auchgestestet und läuft. Du müsstest dazu aber vorher im VBE bei den Verweisen was extra anklicken. UNd zwar sollten noch die zwei letzten Werte hinzugefügt werden. Falls das nicht passiert oder fehlschlägt, kommt beim Start die Meldung, dass ein Variable nicht dfiniert wurden. Hier mal das Bild

Wie aufran auch schon im Code hat mindestens das letzte - Microsoft Scrpting Runtime - anklicken (steht alphabetisch unten). Die zwei darüber habe ich auch mal mit genommen und hat zumindest der Codeausführung nicht geschadet.

Wenn du das hast, könntest du (theoretisch :-) ) den folgdenden Code verwenden. Da ist jetzt zumindest das Öffnen schneller. Da Methoden/Befehle auf das Recordset fehlgeschlagen sind (kam immer ein Fehler), Werte ich die nicht mit find aus, sondern gehe sie in einer Schleife durch. Falls es klappt, schau mal bitte ob das noch etwas schneller ist. VG

 

Dim dateien()

Option Explicit
    
Sub DateienLesen2()
      
Dim DateiName As String
Dim quelle As String
Dim i As Long
Dim j As Long
Dim Dateialt As String
Dim zeilealt As Long
Dim Namekurz As String
Dim Blatt As Object
Dim gefunden As Boolean
Dim suchwert As Variant
Dim suche As Variant
Dim oAdoConnection
Dim sAdoConnectString
Dim oAdoRecordset
Dim oAdoRecordset2
Dim ssql
Dim satz
Dim k

Application.ScreenUpdating = False
   
   
Dateialt = ThisWorkbook.name
zeilealt = 1
ActiveSheet.Columns(1).ClearContents

suchwert = InputBox("Zu suchenden Wert eingeben!", "Suchtexteingabe")
  
If suchwert = "" Then
    MsgBox "Sie haben keinen Wert eingegeben oder Abbrechen angeklickt. Das Program wird beendet.", , "Abbruch Eingaben"
    End
End If
  
ReDim dateien(0)
dateien(0) = 0
        
quelle = "V:\0101\SCHULEN\0-FAHRT"
If Right(quelle, 1) = "\" Then quelle = Left(quelle, Len(quelle) - 1)
 
If Dir(quelle & "\") = "" Then
    MsgBox "Der Pfad wurde nicht gefunden!"
    End
End If
 


    Call txtsuchen2("1" & quelle)

 
If dateien(0) = 0 Then
MsgBox "Keine .txt Dateien gefunden!"
Else
'Daten auslesen
           
    For i = 1 To dateien(0)
    DateiName = dateien(i)
    Namekurz = Right(DateiName, InStr(1, StrReverse(DateiName), "\") - 1)
    gefunden = False
      
'#####################################################################################
    Set oAdoConnection = CreateObject("ADODB.CONNECTION")

    If Val(Application.Version) > 11 Then
    'ab Excel 2007
        sAdoConnectString = "Provider=Microsoft.ACE.OLEDB.12.0; Extended Properties='Excel 12.0 Xml;HDR=No';Data Source=" & DateiName
    Else
    'Excl 2003
        sAdoConnectString = "Provider=Microsoft.ACE.OLEDB.12.0; Extended Properties='Excel 8.0;HDR=No';Data Source=" & DateiName
    End If

    oAdoConnection.Open sAdoConnectString
    Set oAdoRecordset = CreateObject("ADODB.RECORDSET")
    Set oAdoRecordset = oAdoConnection.OpenSchema(20)
   
    While Not oAdoRecordset.EOF
            ssql = "SELECT * from " & Chr(91) & oAdoRecordset.Fields(2).Value & Chr(93)
            Set oAdoRecordset2 = CreateObject("ADODB.RECORDSET")
            oAdoRecordset2.Open ssql, oAdoConnection, adOpenKeyset, adLockReadOnly
            If Not oAdoRecordset2.EOF Then
            
                satz = oAdoRecordset2.GetRows
               
                 For Each k In satz
                    If k <> 0 Then If InStr(1, k, suchwert, vbTextCompare) Then gefunden = True
                 Next

            End If
            oAdoRecordset.MoveNext
    Wend

    oAdoRecordset.Close
    oAdoRecordset2.Close
    oAdoConnection.Close
      
    Set oAdoRecordset = Nothing
    Set oAdoRecordset2 = Nothing
    Set oAdoConnection = Nothing
    
    
    If gefunden = True Then
        ActiveSheet.Hyperlinks.Add anchor:=ActiveSheet.Cells(zeilealt, 1), Address:=DateiName, TextToDisplay:=Namekurz
        zeilealt = zeilealt + 2
    End If
  
    Next i
End If
           
End Sub
     
  
   
Function txtsuchen2(pfads As String)
Dim suche
Dim i As Long
Dim quelle As String
Dim oOrdner
Dim oDateien
Dim datsystem
Dim knoten
Dim datei
Dim ablage
Dim dname As String
Dim onam As String
Dim anfang
 
Set datsystem = CreateObject("Scripting.FileSystemObject")
quelle = pfads
 
anfang = Left(pfads, 1)
quelle = Right(pfads, Len(pfads) - 1)
 
ChDrive (Left(quelle & "\", 3))
ChDir (quelle)
Set knoten = datsystem.GetFolder(quelle)
 
Set oDateien = knoten.Files
Set oOrdner = knoten.SubFolders
 
For Each ablage In oOrdner
    onam = ablage.name
        If Left(onam, 1) <> "." Then
            If anfang <> "x" Then
            ' tiefe ab der der filter greift
                If anfang = 2 Then
                    Call txtsuchen2("x" & ablage.Path)
                Else
                    Call txtsuchen2((anfang + 1) & ablage.Path)
                End If
            Else
                If InStr(1, onam, "16", 1) > 0 Or InStr(1, onam, "Region", 1) > 0 Or InStr(1, onam, "Rahmenvertrag", 1) > 0 Or InStr(1, onam, "Abrechnung", 1) > 0 Then
                    If InStr(1, onam, "Änderung", 1) > 0 Or InStr(1, onam, "Fahrpl", 1) > 0 Or InStr(1, onam, "14", 1) > 0 Or InStr(1, onam, "13", 1) > 0 Or InStr(1, onam, "12", 1) > 0 Or InStr(1, onam, "11", 1) > 0 Or InStr(1, onam, "10", 1) > 0 Then
                    ' die Werete gefunden, da nichts machen
                    Else
                       Call txtsuchen2("x" & ablage.Path)
                    End If
                End If
            End If
        End If
Next ablage
 
If oOrdner.Count = 0 Then
For Each datei In oDateien
    dname = datei.name
        If Left(dname, 1) <> "." Then
             
            If Right(dname, 4) = ".xls" Then    'ggf. noch an xlsx anpassen etc. aber auch die Zahl dazu
                If (InStr(1, dname, "_Planung", 1) > 0 Or InStr(1, dname, "_planung", 1) > 0 Or InStr(1, dname, "_PLANUNG", 1) > 0) And InStr(1, dname, "2016", 1) > 0 Then
                dateien(0) = dateien(0) + 1
                ReDim Preserve dateien(dateien(0))
                dateien(dateien(0)) = datei.Path
                End If
            End If
        End If
Next datei
End If

Set datsystem = Nothing
Set knoten = Nothing
Set oDateien = Nothing
Set oOrdner = Nothing
 
Application.ScreenUpdating = True

 
End Function

 


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
05.01.2016 07:03:28 Andre
NotSolved
06.01.2016 15:27:50 Gast28524
NotSolved
06.01.2016 15:40:24 Andre
NotSolved
06.01.2016 16:20:53 Gast25935
NotSolved
07.01.2016 07:56:43 Andre
NotSolved
06.01.2016 22:17:39 Gast69812
NotSolved
07.01.2016 05:51:07 Gast10186
NotSolved
07.01.2016 07:45:58 Andre
NotSolved
07.01.2016 08:06:27 Andre
NotSolved
09.01.2016 19:10:40 Gast62795
NotSolved
11.01.2016 08:20:07 Andre
NotSolved
11.01.2016 10:22:55 Gast7783
NotSolved
11.01.2016 12:36:32 Andre
NotSolved
11.01.2016 12:39:35 Andre
NotSolved
11.01.2016 15:56:45 Gast87431
NotSolved
11.01.2016 16:14:03 Andre
NotSolved
11.01.2016 16:30:15 Gast67223
NotSolved
12.01.2016 08:21:54 Gast77619
NotSolved
11.01.2016 16:34:42 Gast89738
NotSolved
12.01.2016 08:27:34 Andre
NotSolved
12.01.2016 12:41:22 Gast14356
NotSolved
12.01.2016 14:12:59 Andre
NotSolved
12.01.2016 14:17:04 Andre
NotSolved
12.01.2016 15:46:33 Gast57141
NotSolved
13.01.2016 07:56:18 Andre
NotSolved
13.01.2016 08:09:51 Andre
NotSolved
13.01.2016 08:32:16 Gast86894
NotSolved
13.01.2016 08:42:11 Andre
NotSolved
13.01.2016 19:20:12 Gast86704
NotSolved
14.01.2016 08:32:14 Andre
NotSolved
14.01.2016 10:10:53 Gast34177
NotSolved
14.01.2016 10:28:38 Andre
NotSolved
14.01.2016 10:45:46 Gast25298
NotSolved
14.01.2016 10:58:07 Andre
NotSolved
14.01.2016 11:33:50 Gast21502
NotSolved
14.01.2016 12:18:11 Andre
NotSolved
14.01.2016 15:49:42 Gast23760
NotSolved
14.01.2016 16:09:09 Andre
****
NotSolved
14.01.2016 18:55:41 Gast81853
NotSolved
15.01.2016 08:18:04 Andre
NotSolved
15.01.2016 19:30:59 Gast45694
NotSolved
18.01.2016 08:09:01 Andre
NotSolved
18.01.2016 08:12:08 Andre
NotSolved
18.01.2016 18:02:48 Gast82440
NotSolved
19.01.2016 08:40:26 Andre
NotSolved
19.01.2016 13:36:07 Gast75130
NotSolved
19.01.2016 14:04:24 Andre
NotSolved
19.01.2016 18:19:20 Gast65228
NotSolved
19.01.2016 18:20:55 Gast29977
NotSolved
20.01.2016 07:21:35 Andre
NotSolved
20.01.2016 11:42:16 aufran
NotSolved
20.01.2016 11:54:57 Andre
NotSolved
20.01.2016 12:03:47 Gast44577
NotSolved
20.01.2016 15:58:00 aufran
NotSolved
21.01.2016 21:41:23 aufran
NotSolved
21.01.2016 21:52:00 Gast14641
NotSolved
20.01.2016 12:01:05 Gast18965
NotSolved
20.01.2016 12:07:06 Gast343
NotSolved
20.01.2016 12:18:06 Andre
NotSolved
20.01.2016 12:28:46 Gast95544
Solved
20.01.2016 20:02:43 Gast15375
NotSolved
21.01.2016 07:52:14 Andre
NotSolved
21.01.2016 10:46:39 Gast54269
NotSolved
21.01.2016 10:59:39 Gast19460
NotSolved
21.01.2016 15:04:13 Andre
NotSolved
21.01.2016 15:09:07 Andre
NotSolved
21.01.2016 15:55:44 Gast30371
NotSolved
25.01.2016 07:53:22 Andre
NotSolved
25.01.2016 08:35:01 Andre
NotSolved
25.01.2016 08:35:07 Andre
NotSolved
22.01.2016 13:51:05 Gast11423
NotSolved
22.01.2016 22:45:16 aufran
NotSolved
25.01.2016 08:08:43 Andre
NotSolved
25.01.2016 11:18:33 aufran
NotSolved
25.01.2016 12:07:03 Andre
NotSolved
25.01.2016 08:06:16 Andre
NotSolved
25.01.2016 19:38:52 Gast92881
NotSolved
25.01.2016 19:40:23 Gast31903
NotSolved
26.01.2016 07:26:40 Andre
NotSolved
26.01.2016 09:25:34 Gast31028
NotSolved
26.01.2016 10:15:47 Andre
NotSolved
26.01.2016 11:48:57 Gast10723
NotSolved
26.01.2016 13:23:31 Andre
NotSolved
Blau Durchsuchen von bestimmten Exceldateien mit Hilfe von einem Makro Exce
27.01.2016 14:23:48 Gast20611
NotSolved
27.01.2016 14:48:05 Andre
NotSolved
27.01.2016 14:56:24 Andre
NotSolved
27.01.2016 15:30:27 Gast76603
NotSolved
27.01.2016 15:30:28 Gast42470
NotSolved
27.01.2016 15:57:14 Andre
NotSolved
27.01.2016 16:21:33 Andre
NotSolved
27.01.2016 20:54:35 Gast808
NotSolved
28.01.2016 07:25:57 Andre
NotSolved
28.01.2016 16:20:47 Gast66068
Solved
29.01.2016 12:28:40 Andre
NotSolved
29.01.2016 17:35:37 Gast3880
NotSolved
30.01.2016 10:06:13 aufran
NotSolved