mit unten stehendem Makro lese ich eine csv Datei in eine Tabelle ein.
Dabei wird die Zelle auch als Text formatiert.
Dennoch werden die Zellen nicht als Zahl erkannt, denn Summen gehen nicht
und wenn ich mehrere Zellen markiere, kommt unten in der Statusleiste auch nicht die
Summe, sondern lediglich die Anzahl der markierten Zellen.
Mir ist das am Anfang nicht aufgefallen, weil ich diese Prüfung ausgeschaltet habe (siehe zweites Makro),
aber es erscheint ein gelbes Ausrufezeichen mit der Meldung "Zahl als Text formatiert oder Apostroph vorangestellt". Rechtsklick auf die Zelle ist aber Zahl mit 0 Nachkommastellen eingestellt.
Was also mache ich falsch? In dem csv file gibt es Text und Zahlenfelder, die ich später in
der Tabelle mit Numberformat formatiere, aber das bringt anscheinend nichts.
In dem CSV Import kann ich leider nicht beeinflussen welche Spalte mit welcher
Formatierung eingelesen wird, also setze ich immer das Format auf Zahl.
Kann bitte jemand helfen?
Private Function ReadfromCSVSimple(WS As Worksheet, fname As String, Optional FS As String = ";" _
_
)
Dim hfile As Integer ' Filehandle bzw. Dateinummer
Dim i As Long ' Zähler über alle Zeilen
Dim OneLine As String ' Eine Zeile als String
Dim myArr As Variant ' eine Zeile in Felder getrennt
hfile = FreeFile
Open fname For Input As #hfile
While Not EOF(hfile)
i = i + 1
Line Input #hfile, OneLine
myArr = Split(OneLine, FS)
With WS.Range(WS.Cells(i, 1), WS.Cells(i, 1 + UBound(myArr)))
.NumberFormat = "0"
.Value = myArr
End With
Wend
Close #hfile
End Function
Sub ApplicationSettings(ByVal blnSwitch As Boolean)
Application.ErrorCheckingOptions.NumberAsText = blnSwitch
Application.ErrorCheckingOptions.BackgroundChecking = blnSwitch
Application.ErrorCheckingOptions.EmptyCellReferences = blnSwitch
Application.ErrorCheckingOptions.EvaluateToError = blnSwitch
Application.ErrorCheckingOptions.InconsistentFormula = blnSwitch
Application.ErrorCheckingOptions.ListDataValidation = blnSwitch
Application.ErrorCheckingOptions.OmittedCells = blnSwitch
Application.ErrorCheckingOptions.UnlockedFormulaCells = blnSwitch
Application.ErrorCheckingOptions.TextDate = blnSwitch
End Sub