Ich baue gerade ein Tool, mit welchem durch mehrere User Ausbildungen (Soll und Ist) erfasst werden soll.
Bei mir auf dem Computer läuft soweit alles gut.
Beim letzten Test mit 12 verschiedenen Usern sind dann jedoch immer wieder Fehler aufgetreten.
Unteranderem ist das Excel bei 4 der User abgestürzt (geschlossen und dann automatisch wieder geöffnet), sobald sie Buttons die UserForms aufrufen geklickt haben.
Bei all diesen 4 User, ist der Fehler nicht immer und nicht immer beim gleichen Button aufgetreten.
So weit ich weiss haben alle diese eine neuere Version wenn nicht sogar Excel 365.
Leider kann ich nach Recherche noch immer keinen Fehler finden und hoffe, dass mir vielleicht hier jemand weiterhelfen kann?
Ich hoffe euch stehen nicht gleich eure Haare zu Berg wenn ihr meine beschränkten zusammengebastelten VBA Codes seht!
Für eure Hilfe wäre ich sehr dankbar.
Folgend der Code bei zwei Buttons wo der Fehler manchmal aufgetreten ist:
UFSollKompetenzPerRolle.Show vbModeless
End Sub
Private Sub CommandButton1_Click()
Application.ScreenUpdating = False
'Application.Calculation = xlCalculationManual
'Check Rolle
If ComboBox3.Value = "" Then
MsgBox "Rolle / Qualifikationsprofil ausw?hlen"
Exit Sub
End If
Dim iy As Integer
Dim ix As Integer
Dim ik As Integer
Dim iSelCnt As Integer
Dim a As Integer
Dim ih As Integer
'Filter l?schen
ThisWorkbook.Worksheets("Soll Qualifikations Profile").Range("B2").AutoFilter
ThisWorkbook.Worksheets("Soll Qualifikations Profile").Range("B2").AutoFilter
iSelCnt = 0
For ix = 0 To ListBox1.ListCount - 1
If ListBox1.Selected(ix) = True Then iSelCnt = iSelCnt + 1
Next ix
'Check Kompetenz
If iSelCnt = 0 Then
MsgBox "Bitte Kompetenz ausw?hlen"
Exit Sub
End If
'Check Level
For iy = 4 To iSelCnt + 3
If Me.Controls("ComboBox" & iy) = "" Then
MsgBox "Bitte zu jeder Kompetenz das n?tige Kompetzenz Level w?hlen"
Exit Sub
End If
Next iy
a = ThisWorkbook.Worksheets("Soll Qualifikations Profile").Range("B1048576").End(xlUp).Row + 1
'check if selection already exists same level
For ik = 1 To iSelCnt
If Application.WorksheetFunction.CountIf(ThisWorkbook.Worksheets("Soll Qualifikations _
Profile").Range("H:H"), _
ComboBox3 & ";" & Me.Controls("TextBox" & ik) & ";" & Me.Controls("ComboBox" & ik + 3)) _
> 0 Then
MsgBox "Sollkompetenz: " & ComboBox3.Value & " bereits mit " & vbNewLine & Me. _
Controls("TextBox" & ik) & " kombiniert." & vbNewLine & "Bitte Auswahl aufheben."
Exit Sub
End If
'check if selection already exist with different level -> overwrite yes/no?
Dim s As Integer
Dim YesClick As Integer
For ih = a To 3 Step -1
If ComboBox3 = ThisWorkbook.Worksheets("Soll Qualifikations Profile").Cells(ih, 2) _
And _
Me.Controls("TextBox" & ik) = ThisWorkbook.Worksheets("Soll Qualifikations Profile") _
.Cells(ih, 3) Then
Dim answer As Integer
answer = MsgBox("Rolle: " & ComboBox3 & vbNewLine & " Kompetenz: " & Me.Controls(" _
TextBox" & ik) & vbNewLine & " wurdenen bereits mit dem Level " & ThisWorkbook.Worksheets("Soll Qualifikations Profile").Cells(ih, 4) & " verbunden. " & vbNewLine & "Soll diese verkn?pfung gel?scht werden?", vbQuestion + vbYesNo)
If answer = vbYes Then
YesClick = YesClick + 1
ThisWorkbook.Worksheets("Soll Qualifikations Profile").Range(ThisWorkbook. _
Worksheets("Soll Qualifikations Profile").Cells(ih, 2), ThisWorkbook.Worksheets("Soll Qualifikations Profile").Cells(ih, 11)).Copy
s = ThisWorkbook.Worksheets("Soll Qualifikations Profile").Range("S1048576") _
.End(xlUp).Row + 1
If ThisWorkbook.Worksheets("Soll Qualifikations Profile").Cells(s - 1, 19) = _
"" Then
s = s - 1
End If
ThisWorkbook.Worksheets("Soll Qualifikations Profile").Cells(s, 19). _
PasteSpecial xlPasteValuesAndNumberFormats
ThisWorkbook.Worksheets("Soll Qualifikations Profile").Range(ThisWorkbook. _
Worksheets("Soll Qualifikations Profile").Cells(ih, 2), ThisWorkbook.Worksheets("Soll Qualifikations Profile").Cells(ih, 11)).Delete
ThisWorkbook.Worksheets("Soll Qualifikations Profile").Cells(s, 29) = _
ThisWorkbook.Path
ThisWorkbook.Worksheets("Soll Qualifikations Profile").Cells(s, 30) = Environ(" _
username")
ThisWorkbook.Worksheets("Soll Qualifikations Profile").Cells(s, 31) = CDate(Now) _
ThisWorkbook.Worksheets("Soll Qualifikations Profile").Cells(s, 32) = "Rolle _
Kompetenz ?berschrieben"
End If
End If
If answer = vbNo Then
If YesClick > 0 Then
MsgBox "Sollkompetenz: " & ComboBox3.Value & vbNewLine & "bereits mit: " & _
Me.Controls("TextBox" & ik) & "- kombiniert. " & vbNewLine & "Bitte Auswahl aufheben." & vbNewLine & " " & vbNewLine & "ACHTUNG! Es wurden bereits Verkn?pfungen gel?scht! & vbNewLine & diese m?ssen evtl. erneut vergeben werden"
Exit Sub
Else
MsgBox "Sollkompetenz: " & ComboBox3.Value & vbNewLine & "bereits mit: " & _
Me.Controls("TextBox" & ik) & "- kombiniert. " & vbNewLine & "Bitte Auswahl aufheben."
Exit Sub
End If
End If
Next ih
Next ik
a = ThisWorkbook.Worksheets("Soll Qualifikations Profile").Range("B1048576").End(xlUp).Row + 1
If ThisWorkbook.Worksheets("Soll Qualifikations Profile").Cells(a - 1, 2) = "" Then
a = a - 1
End If
Dim b As Integer
For b = 1 To iSelCnt
ThisWorkbook.Worksheets("Soll Qualifikations Profile").Cells(a, 2) = ComboBox3
ThisWorkbook.Worksheets("Soll Qualifikations Profile").Cells(a, 3) = Me.Controls("TextBox" & _
b)
ThisWorkbook.Worksheets("Soll Qualifikations Profile").Cells(a, 4) = CDbl(Me.Controls(" _
ComboBox" & b + 3))
ThisWorkbook.Worksheets("Soll Qualifikations Profile").Cells(a, 5) = TextBox11
ThisWorkbook.Worksheets("Soll Qualifikations Profile").Cells(a, 7) = 1
ThisWorkbook.Worksheets("Soll Qualifikations Profile").Cells(a, 8) = ComboBox3 & ";" & Me. _
Controls("TextBox" & b) & ";" & Me.Controls("ComboBox" & b + 3)
ThisWorkbook.Worksheets("Soll Qualifikations Profile").Cells(a, 9) = ThisWorkbook. _
Worksheets("Data Base").Cells(2, 2) & ";" & _
Me.Controls("TextBox" & b) & ";" & _
Me.Controls("ComboBox" & b + 3)
ThisWorkbook.Worksheets("Soll Qualifikations Profile").Cells(a, 10) = Environ("username")
ThisWorkbook.Worksheets("Soll Qualifikations Profile").Cells(a, 11) = CLng(Now)
ThisWorkbook.Worksheets("Soll Qualifikations Profile").Cells(a, 12) = ThisWorkbook.Path
a = a + 1
Next b
'Modul 1
Call CheckTable
MsgBox "Rolle / Qualifikationsprofil mit Kompetenz verbunden"
'Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
Unload UFSollKompetenzPerRolle
End Sub
Private Sub CommandButton2_Click()
Dim k As Integer
Dim i As Integer
For k = 0 To ListBox1.ListCount - 1
If ListBox1.Selected(k) = True Then ListBox1.Selected(k) = False
Next k
For i = 4 To 13
Me.Controls("ComboBox" & i) = ""
Next i
End Sub
Private Sub ListBox1_Change()
TextBox1 = ""
TextBox2 = ""
TextBox3 = ""
TextBox4 = ""
TextBox5 = ""
TextBox6 = ""
TextBox7 = ""
TextBox8 = ""
TextBox9 = ""
TextBox10 = ""
Dim i As Integer
Dim e As Integer
Dim iSelCnt As Integer
Dim ix As Integer
iSelCnt = 0
For ix = 0 To ListBox1.ListCount - 1
If ListBox1.Selected(ix) = True Then iSelCnt = iSelCnt + 1
Next ix
If iSelCnt > 10 Then
MsgBox "Es k?nnen maximal 10 Kompetenzen ausgew?hlt werden" & vbNewLine & "Weitere _
Kompetenzen k?nne nachtr?glich unter der selben Rolle/Q-Profil erg?nzt werden."
Else
e = 1
For i = 0 To ListBox1.ListCount - 1
If ListBox1.Selected(i) Then
Me.Controls("TextBox" & e) = ListBox1.List(i)
e = e + 1
End If
Next i
End If
End Sub
und
UFMitarbeiterNummer.Show vbModeless
End Sub
Private Sub CommandButton1_Click()
Dim SourceFile As Object
Dim TargetFile As Object
Dim a As Integer
Dim d As Integer
If Not IsNumeric(TextBox4.Value) Then
MsgBox "Personal Nummer muss eine Nummer sein"
Exit Sub
End If
If Application.WorksheetFunction.CountIf(ThisWorkbook.Worksheets("Data Base").Range("AN:AN"), _
CLng(TextBox4)) > 0 Then
MsgBox "Personal Nummer Bereits vergeben"
Exit Sub
End If
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Call fileName
Set SourceFile = Workbooks.Open(trgPfad & trg, 0)
Set TargetFile = ThisWorkbook
Dim TWB As String
TWB = "Data Base"
Dim SWB As String
SWB = "All Base Data"
a = TargetFile.Worksheets(TWB).Range("AN1048576").End(xlUp).Row + 1
If TargetFile.Worksheets(TWB).Cells(a - 1, 38) = "" Then
a = a - 1
End If
If Application.WorksheetFunction.CountIf(Workbooks(trg2).Worksheets(SWB).Range(Workbooks(trg2). _
Worksheets(SWB).Cells(5, 40), Workbooks(trg2).Worksheets(SWB).Cells(5000, 40)), "=" & CLng(TextBox4)) > 0 Then
d = WorksheetFunction.Match(CLng(TextBox4), Workbooks(trg2).Worksheets(SWB).Range(Workbooks( _
trg2).Worksheets(SWB).Cells(1, 40), Workbooks(trg2).Worksheets(SWB).Cells(5000, 40)), 0)
Workbooks(trg2).Worksheets(SWB).Range(Workbooks(trg2).Worksheets(SWB).Cells(d, 38), Workbooks( _
trg2).Worksheets(SWB).Cells(d, 44)).Copy
TargetFile.Worksheets(TWB).Range(TargetFile.Worksheets(TWB).Cells(a, 38), TargetFile.Worksheets( _
TWB).Cells(a, 44)).PasteSpecial Paste:=xlValues
TargetFile.Worksheets(TWB).Cells(a, 45) = Environ("username")
TargetFile.Worksheets(TWB).Cells(a, 46) = CDate(Now)
End If
If Not Application.WorksheetFunction.CountIf(Workbooks(trg2).Worksheets(SWB).Range(Workbooks( _
trg2).Worksheets(SWB).Cells(5, 40), Workbooks(trg2).Worksheets(SWB).Cells(5000, 40)), "=" & CLngLng(TextBox4)) > 0 Then
MsgBox "Die Personalnummer " & TextBox4 & " ist in der Daten Bank noch keinem Mitarbeiter _
zugewiesen. Bitte Details zu dieser Person erg?nzen."
UFMitarbeiterNummer.Hide
Workbooks(trg2).Close savechanges:=False
Application.Calculation = xlCalculationAutomatic 'Formelkalkulation wieder einschalten
Application.ScreenUpdating = True
UFMitarbeiter.TextBox4 = UFMitarbeiterNummer.TextBox4
UFMitarbeiter.Show
Exit Sub
End If
UFMitarbeiterNummer.Hide
'Modul 4
Call GetEmployeeRecords
Unload UFMitarbeiterNummer
MsgBox "Mitarbeiter " & TargetFile.Worksheets(TWB).Cells(a, 38) & " wurde importiert"
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
End Sub
Viele Grüsse