Thema Datum  Von Nutzer Rating
Antwort
Rot Userform Daten (Zahlen) werden nicht erkannt
26.09.2015 13:10:11 julz
NotSolved
26.09.2015 16:50:50 Gast10909
*
NotSolved
28.09.2015 12:35:21 julz
NotSolved
28.09.2015 23:07:25 julz
NotSolved

Ansicht des Beitrags:
Von:
julz
Datum:
26.09.2015 13:10:11
Views:
1112
Rating: Antwort:
  Ja
Thema:
Userform Daten (Zahlen) werden nicht erkannt

Hallo!

Ich bin ein VBA Anfänger und habe folgendes Problem:

Wenn ich Daten über meine Userform eingebe werden diese zunächst von der Tabelle nicht "erkannt". Bsp: Eingabe von "2,5" über eine Userform ComboBox steht dann zwar in der entsprechenden Zelle, aber in einer weiteren Tabelle, die Werte summiert, wird es nicht als Wert erkannt. Erst wenn ich die Zelle einmal doppelklicke wird es auch von der anderen Tabelle summiert. Genauso mit dem Datum was ich in der Form tt-mm eingeben lasse. Nach doppelklick wird es als Datum umformatiert. Wie kommt das? Was mach ich falsch?

Private Sub ComboBox1_Change()

End Sub


Private Sub ListBox1_Click()

End Sub

Private Sub Label4_Click()

End Sub

Private Sub TextBox3_Change()

End Sub

Private Sub TextBox6_Change()

End Sub

Private Sub UserForm_Initialize()
'when the Userform is initialized, set focus to TextBox6
 Me.TextBox6.SetFocus
  'fill ComboBox
    With Me.ComboBox3
.AddItem "JM"
.AddItem "MK"
.AddItem "BH"

.ListIndex = 0
End With

  With Me.ComboBox1
  .AddItem "EIKS_AB"
.AddItem "PV_JIRA_WF"
.AddItem "PMO"
.AddItem "Projektmanagement"
.AddItem "PMO_WIKI"
.AddItem "Sonstiges"
.ListIndex = 3
  End With
  
  With Me.ComboBox2
.AddItem "0,5"
.AddItem "1,0"
.AddItem "1,5"
.AddItem "2,0"
.AddItem "2,5"
.AddItem "3,0"
.AddItem "3,5"
.AddItem "4,0"
.AddItem "4,5"
.AddItem "5,0"
.AddItem "5,5"
.AddItem "6,0"
.AddItem "6,5"
.AddItem "7,0"
.AddItem "7,5"
.AddItem "8,0"
.AddItem "8,5"
.ListIndex = 4
End With

  
End Sub
Private Sub CommandButton1_Click()

           Dim i As Integer

    'position cursor in the correct cell A2.
      Sheets("Display").Activate
      Range("A2").Select
    i = 1 'set as the first ID

    'validate if data has been entered
    If Me.TextBox3.Text = Empty Then 'Datum
        MsgBox "Bitte Datum eingeben.", vbExclamation
        Me.TextBox3.SetFocus 'position cursor to try again
        Exit Sub 'terminate here - why continue?
          End If
 
If Len(TextBox3.Text) < 5 Then 'Datum
        MsgBox "Bitte überprüfe die Datums Eingabe.", vbExclamation
        Me.TextBox3.SetFocus
        Exit Sub
    End If

If Len(TextBox3.Text) > 5 Then 'Datum
        MsgBox "Bitte überprüfe die Datums Eingabe.", vbExclamation
        Me.TextBox3.SetFocus
        Exit Sub
    End If
 
   If Me.ComboBox1.Text = Empty Then 'Projekt
        MsgBox "Bitte Projekt auswählen.", vbExclamation
        Me.ComboBox1.SetFocus 'position cursor to try again
        Exit Sub 'terminate here - why continue?
    End If
    
    If Me.ComboBox2.Value = Empty Then 'Stunden
        MsgBox "Bitte Stunden auswählen.", vbExclamation
        Me.ComboBox2.SetFocus 'position cursor to try again
        Exit Sub 'terminate here - why continue?
    End If


    If Me.ComboBox3.Text = Empty Then 'Mitarbeiter
        MsgBox "Bitte Mitarbeiter Kürzel auswählen.", vbExclamation
        Me.ComboBox3.SetFocus 'position cursor to try again
        Exit Sub 'terminate here - why continue?
    End If
         
    Dim strPass As String

strPass = "student"
    
    If Me.TextBox6.Text = Empty Then 'Passwort
        MsgBox "Bitte Passwort eingeben.", vbExclamation
        Me.TextBox6.SetFocus 'position cursor to try again
        Exit Sub 'terminate here - why continue?
    End If

If Me.TextBox6.Text = strPass Then 'Passwort
        MsgBox "Ihre Eingabe wurde gespeichert. Änderungen können nur als Administrator vorgenommen werden.", vbExclamation
        UnProtected = True
       Else
    If MsgBox("Das Passwort ist falsch. Bitte geben Sie das richtige Passwort ein.", vbYesNo) = vbNo Then
        Unload Me
    Else
        Exit Sub
    End If
End If


        
    'if all the above are false (OK) then carry on.
    'check to see the next available blank row start at cell A2...
    Do Until ActiveCell.Value = Empty
        ActiveCell.Offset(1, 0).Select 'move down 1 row
        i = i + 1 'keep a count of the ID for later use
    Loop

    'Populate the new data values into the 'Data' worksheet.
    
     ActiveCell.Value = Me.TextBox3.Text 'set col A
    ActiveCell.Offset(0, 1).Value = Me.ComboBox1.Text 'set col B
    ActiveCell.Offset(0, 2).Value = Me.ComboBox2.Value 'set col C
    ActiveCell.Offset(0, 3).Value = Me.ComboBox3.Text 'set col D
    ActiveCell.Offset(0, 4).Value = Me.TextBox5.Text 'set col E


'End and make new entry
   ActiveWorkbook.Worksheets("Display").ListObjects("Tabelle1").Sort.SortFields. _
        Clear
    ActiveWorkbook.Worksheets("Display").ListObjects("Tabelle1").Sort.SortFields. _
        Add Key:=Range("Tabelle1[[#All],[Datum]]"), SortOn:=xlSortOnValues, Order _
        :=xlDescending, DataOption:=xlSortNormal
    With ActiveWorkbook.Worksheets("Display").ListObjects("Tabelle1").Sort
        .Header = xlYes
        .MatchCase = False
        .Orientation = xlTopToBottom
        .SortMethod = xlPinYin
        .Apply
    End With
   ActiveWorkbook.Save

   
    'Clear down the values ready for the next record entry...
    Me.ComboBox1.Text = Empty
     
   Me.TextBox3.Text = Empty
Me.TextBox5.Text = Empty


    Me.TextBox3.SetFocus 'positions the cursor for next record entry

End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not UnProtected Then Mitarbeiter1.Show
End Sub

      

'Beenden Schaltfläche Ereignisroutine
Private Sub CommandButton2_Click()
     Unload Me
End Sub

 


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
Rot Userform Daten (Zahlen) werden nicht erkannt
26.09.2015 13:10:11 julz
NotSolved
26.09.2015 16:50:50 Gast10909
*
NotSolved
28.09.2015 12:35:21 julz
NotSolved
28.09.2015 23:07:25 julz
NotSolved