Live-Forum - Die aktuellen Beiträge
Datum
Titel
17.04.2024 18:57:33
17.04.2024 16:56:58
Anzeige
Archiv - Navigation
1648to1652
Aktuelles Verzeichnis
Verzeichnis Index
Übersicht Verzeichnisse
Vorheriger Thread
Rückwärts Blättern
Nächster Thread
Vorwärts blättern
Anzeige
HERBERS
Excel-Forum (Archiv)
20+ Jahre Excel-Kompetenz: Von Anwendern, für Anwender
Inhaltsverzeichnis

Datum v. Text Importe werden nicht sortiert

Datum v. Text Importe werden nicht sortiert
06.10.2018 13:07:30
Stefan
Hi und guten Tag,
In meiner liste werden komischer weise die Text Importe aus Text Datein nicht mit den Händisch eingetragenen Inhalten sortiert.
Das Problem hierbei ist das Datum in der Spalte A. Die Spalte A ist als Datum eingestellt. Lösche ich nun das Datum aus der Zeile raus das aus der Text Datei kam und schreibe es Händisch rein funktioniert die Sortierung wieder.
Wer kann mir hierbei helfen.
Beste Grüße
Stefan

13
Beiträge zum Forumthread
Beiträge zu diesem Forumthread

Betreff
Datum
Anwender
Anzeige
AW: Datum v. Text Importe werden nicht sortiert
06.10.2018 13:11:02
Hajo_Zi
Halo Stefan,
es ist Text der aussieht wie Text. Typ(A1)=2

Beiträge von Werner, Luc, robert, J.O.Maximo und folgende lese ich nicht.
AW: Datum v. Text Importe werden nicht sortiert
06.10.2018 13:23:54
Stefan
Hallo Hajo,
Was meinst du ?
Was soll ich mit der Formel machen ?
Noch als Info, die Text Datei wird via VBA eingetragen.
Grüße Stefan
AW: Datum v. Text Importe werden nicht sortiert
06.10.2018 13:27:24
Stefan
Hallo Hajo,
Was meinst du ?
Was soll ich mit der Formel machen ?
Noch als Info, die Text Datei wird via VBA eingetragen.
Grüße Stefan
AW: Datum v. Text Importe werden nicht sortiert
06.10.2018 13:34:10
Hajo_Zi
Gut Du möchtest die Formel nicht übernehmen.
frage jemand der neben Dir sitzt der sieht die Datei.
Ich sehe Sie nicht.
Gruß Hajo
Anzeige
AW: Datum v. Text Importe werden nicht sortiert
06.10.2018 13:40:39
Stefan
Warum bist du Unhöflich !!!
Ich habe blos gefragt, was ich mit der Formel machen soll !
Sag mir doch einfach, pass auf Formel muss da oder da rein !
Knallst mir hier was hin und ich soll jetzt gedanken lesen oder wie ?
Das ist mir hier ja nie passiert !!!
Schönes Wochenende
AW: Datum v. Text Importe werden nicht sortiert
06.10.2018 13:42:57
Sepp
Hallo Stefan,
Hajo am besten ignorieren, der ist nicht mehr er selbst. Leider sieht er das selber nicht ein!
Wie sieht den dein import-Code aus?
 ABCDEF
1Gruß Sepp
2
3

Anzeige
AW: Datum v. Text Importe werden nicht sortiert
06.10.2018 13:50:51
Stefan
Hi Sepp,
ich glaube der ist sogar von dir
Option Explicit
Sub importFromTextFiles()
Const cstrDirectory As String = "P:\bla\bla\" 'Stammverzeichnis - Anpassen!"
Const clngLastCol As Long = 19 'Spaltennummer der letzten Spalte
Dim strPath As String, varData() As Variant, varTemp As Variant
Dim lngCount As Long, lngIndex As Long, lngN As Long, lngNext As Long, FF As Integer
Dim strFile As String, strTmp As String
With Application.FileDialog(msoFileDialogFolderPicker)
.InitialFileName = cstrDirectory
.Title = "Daten-Import Ordnerauswahl daher keine Dateianzeige !"
.ButtonName = "Datenimport starten"
.InitialView = msoFileDialogViewList
If .Show = -1 Then
strPath = .SelectedItems(1)
If Right(strPath, 1) "\" Then strPath = strPath & "\"
End If
End With
If Len(strPath) Then
If MsgBox("Datenimport starten ?", vbQuestion + vbYesNo) = vbYes Then
lngCount = countFiles(strPath, "*.txt", True)
If lngCount > 0 Then
ReDim varData(1 To lngCount, 1 To clngLastCol)
strFile = Dir(strPath & "*.txt", vbNormal)
Do While strFile ""
FF = FreeFile
Open strPath & strFile For Input As #FF
Input #FF, strTmp
Close #FF
If Len(strTmp) Then
varTemp = Split(strTmp, ";")
lngIndex = lngIndex + 1
For lngN = 1 To UBound(varTemp) + 1
varData(lngIndex, lngN) = varTemp(lngN - 1)
Next
End If
strFile = Dir
Loop
Kill strPath & "*.txt"
With Sheets("Datenbank") 'Tabellenname evtl. anpassen!
lngNext = Application.Max(3, .Cells(.Rows.Count, 1).End(xlUp).Row + 1)
.Cells(lngNext, 1).Resize(UBound(varData, 1), UBound(varData, 2)) = varData
End With
MsgBox "Daten wurden importiert!", vbInformation
Else
MsgBox "Keine Daten zum Import vorhanden!", vbExclamation
End If
End If
End If
End Sub
Private Function countFiles(ByVal Directory As String, Optional ByVal FileName As String = "",  _
Optional ByVal SubFolders As Boolean = False) As Long
Dim objFSO As Object, objFolder As Object, objFile As Object, objSubF As Object
Dim lngCount As Long
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder(Directory)
If Len(FileName) Then
For Each objFile In objFolder.Files
If objFile.Name Like FileName Then lngCount = lngCount + 1
Next
Else
lngCount = objFolder.Files.Count
End If
If SubFolders Then
For Each objSubF In objFolder.SubFolders
lngCount = lngCount + countFiles(objSubF.Path, FileName, SubFolders)
Next
End If
countFiles = lngCount
Set objSubF = Nothing
Set objFile = Nothing
Set objFolder = Nothing
Set objFSO = Nothing
End Function

Anzeige
AW: Datum v. Text Importe werden nicht sortiert
06.10.2018 15:14:14
Sepp
Hallo Stefan,
und wie sieht eine der Textdateien aus?
 ABCDEF
1Gruß Sepp
2
3

Anzeige
AW: Datum v. Text Importe werden nicht sortiert
06.10.2018 15:18:55
Stefan
Hi Sepp,
31.07.2018;Offen;EMA;8465;1;STÖRUNG;;KDW;0;0.04;;;;Fenster MK in Störung;;;;Fenster 01 ausgeblockt wegen Scharfschaltung;Mustermann
Gruß Stefan
AW: Datum v. Text Importe werden nicht sortiert
06.10.2018 15:27:37
Sepp
Hallo Stefan,
auf die Schnelle.
Modul Modul1
Option Explicit 
 
Sub importFromTextFiles() 
  Const cstrDirectory As String = "P:\bla\bla\" 'Stammverzeichnis - Anpassen!" 
  Const clngLastCol As Long = 19 'Spaltennummer der letzten Spalte 
  Dim strPath As String, varData() As Variant, varTemp As Variant 
  Dim lngCount As Long, lngIndex As Long, lngN As Long, lngNext As Long, FF As Integer 
  Dim strFile As String, strTmp As String 
  With Application.FileDialog(msoFileDialogFolderPicker) 
    .InitialFileName = cstrDirectory 
    .Title = "Daten-Import Ordnerauswahl daher keine Dateianzeige !" 
    .ButtonName = "Datenimport starten" 
    .InitialView = msoFileDialogViewList 
    If .Show = -1 Then 
      strPath = .SelectedItems(1) 
      If Right(strPath, 1) <> "\" Then strPath = strPath & "\" 
    End If 
  End With 
  If Len(strPath) Then 
    If MsgBox("Datenimport starten ?", vbQuestion + vbYesNo) = vbYes Then 
      lngCount = countFiles(strPath, "*.txt", True) 
      If lngCount > 0 Then 
        Redim varData(1 To lngCount, 1 To clngLastCol) 
        strFile = Dir(strPath & "*.txt", vbNormal) 
        Do While strFile <> "" 
          FF = FreeFile 
          Open strPath & strFile For Input As #FF 
          Input #FF, strTmp 
          Close #FF 
          If Len(strTmp) Then 
            varTemp = Split(strTmp, ";") 
            lngIndex = lngIndex + 1 
            For lngN = 1 To Ubound(varTemp) + 1 
              If IsDate(varTemp(lngN - 1)) And lngN = 1 Then 
                varData(lngIndex, lngN) = CDate(varTemp(lngN - 1)) 
              Else 
                varData(lngIndex, lngN) = varTemp(lngN - 1) 
              End If 
            Next 
          End If 
          strFile = Dir 
        Loop 
        Kill strPath & "*.txt" 
        With Sheets("Datenbank") 'Tabellenname evtl. anpassen! 
          lngNext = Application.Max(3, .Cells(.Rows.Count, 1).End(xlUp).Row + 1) 
          .Cells(lngNext, 1).Resize(Ubound(varData, 1), Ubound(varData, 2)) = varData 
        End With 
        MsgBox "Daten wurden importiert!", vbInformation 
      Else 
        MsgBox "Keine Daten zum Import vorhanden!", vbExclamation 
      End If 
    End If 
  End If 
End Sub 
 
Private Function countFiles(ByVal Directory As String, Optional ByVal FileName As String = "", _
  Optional ByVal SubFolders As Boolean = False) As Long 
  Dim objFSO As Object, objFolder As Object, objFile As Object, objSubF As Object 
  Dim lngCount As Long 
  Set objFSO = CreateObject("Scripting.FileSystemObject") 
  Set objFolder = objFSO.GetFolder(Directory) 
  If Len(FileName) Then 
    For Each objFile In objFolder.Files 
      If objFile.Name Like FileName Then lngCount = lngCount + 1 
    Next 
  Else 
    lngCount = objFolder.Files.Count 
  End If 
  If SubFolders Then 
    For Each objSubF In objFolder.SubFolders 
      lngCount = lngCount + countFiles(objSubF.Path, FileName, SubFolders) 
    Next 
  End If 
  countFiles = lngCount 
  Set objSubF = Nothing 
  Set objFile = Nothing 
  Set objFolder = Nothing 
  Set objFSO = Nothing 
End Function 
 
 

VBA/HTML-CodeConverter, AddIn für Office 2002-2016 - in VBA geschrieben von Lukas Mosimann. Projektbetreuung:RMH Software & Media

Code erstellt und getestet in Office 16 - mit VBAHTML 12.6.0


 ABCDEF
1Gruß Sepp
2
3

Anzeige
Für Sepp, Perfekt ! Ganz großes Dankeschön o.w.t.
06.10.2018 15:40:02
Stefan
.
AW: Datum v. Text Importe werden nicht sortiert
06.10.2018 13:43:11
Hajo_Zi
trage die Formel in XFD 1048576 eine und es erscheint Wahr, da meine Aussage korrekt ist.
Gruß Hajo
HALT DICH RAUS!!! o.w.T.
06.10.2018 14:07:16
Werner

299 Forumthreads zu ähnlichen Themen

Anzeige
Anzeige
Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige
Anzeige
Anzeige