AW: Du solltest .NumberFormat weglassen und ...
19.01.2014 14:08:31
Uwe
Hallo Luc,
hab ich alles getan aber wenn ich mit Replace die Punkte entferne, wird aus 02.02.20147100 (ID) eine Zahl im wissenschaftlichen Format ausgegeben. (2,022E+10)
Bis zu dem Zeitpunkt wo die ID in die Zelle geschrieben wird, ist das Format=Text (Typ 2), sobald die Punkte ersetzt werden ist das Format=Zahl(Typ 1)
Ich gebs bald auf...
Option Explicit
Sub Test()
Dim SensNr As String
Dim wks As Worksheet
Dim Datum As String
Dim DokNr As String
Dim ID As String
Application.DisplayAlerts = False
Worksheets("Vorlage").Copy after:=Worksheets("Vorlage")
NeueEingabe:
SensNr = InputBox("Sensornummer eingeben:", , "J02.")
If StrPtr(SensNr) = 0 Then
ActiveSheet.Delete
Exit Sub
End If
If StrPtr(SensNr) = 1 Or SensNr = "" Then MsgBox "Sensornummer fehlt!", vbCritical
If Len(SensNr) 9 Then
MsgBox "Sensornummer prüfen!", vbCritical
GoTo NeueEingabe
End If
ActiveSheet.Cells(3, 2) = SensNr
For Each wks In ThisWorkbook.Worksheets
If wks.Name = SensNr Then
MsgBox "Ein Tabellenblatt mit diesem Namen existiert schon!" & vbCrLf _
& "Sensornummer prüfen!", vbCritical
GoTo NeueEingabe
End If
Next
ActiveSheet.Name = SensNr
ActiveSheet.Tab.Color = vbGreen
Do
Datum = InputBox("Datum eingeben:", "erwarte Eingabe...", "TT.MM.JJJJ")
If StrPtr(Datum) = 0 Then
ActiveSheet.Delete
Exit Sub
End If
If StrPtr(Datum) = 1 Or Datum = "" Then MsgBox "Datum zwingend erforderlich!"
If Not IsDate(Datum) Then MsgBox "Das ist kein gültiges Datum!", vbCritical
Loop Until IsDate(Datum)
ActiveSheet.Cells(1, 2) = CStr(Datum)
Do
Nochmal:
DokNr = InputBox("Dokumentennummer eingeben:")
If StrPtr(DokNr) = 0 Then
ActiveSheet.Delete
Exit Sub
End If
If StrPtr(DokNr) = 1 Or DokNr = "" Then
MsgBox "Dokumentennummer fehlt!", vbCritical
GoTo Nochmal
End If
If Not IsNumeric(DokNr) Then
MsgBox "Es sind nur Zahlen zulässig!", vbCritical
GoTo Nochmal
End If
If Len(DokNr) 4 Then
MsgBox "Dokumentennummer muss 4-stellig sein!", vbCritical
GoTo Nochmal
End If
Loop Until IsNumeric(DokNr) And Len(DokNr) = 4
ID = Datum & DokNr
ActiveSheet.Cells(2, 2) = ID
'ActiveSheet.Cells(2, 2).NumberFormat = "@"
ActiveSheet.Cells(2, 2).Replace ".", ""
Application.DisplayAlerts = True
End Sub
Grüße Uwe