08.06.2014, 12:24
Hallo Stefan!
Danke für die Hilfe, funktioniert!
Nun eine neue Frage. Habe mir den Code erweitert ist rot dargestellt. Kann man diesen umschreiben das nicht mehr bei der Berechnung RC drin steht
(Sum = "=SUM(RC[-31],RC[-25],RC[-19],RC[-13],RC[-7],RC[-1])" 'Gesamt vom Siel aus Spalte 8, 14, 20, 26, 32 und 38)?
Danke für die Hilfe :100:
Danke für die Hilfe, funktioniert!
Nun eine neue Frage. Habe mir den Code erweitert ist rot dargestellt. Kann man diesen umschreiben das nicht mehr bei der Berechnung RC drin steht
(Sum = "=SUM(RC[-31],RC[-25],RC[-19],RC[-13],RC[-7],RC[-1])" 'Gesamt vom Siel aus Spalte 8, 14, 20, 26, 32 und 38)?
Code:
Private Sub CommandButton3_Click()
Dim loS As Long
Dim lngZeile As Long
Dim arrSpielAuswahl
Dim arrTreffer
Dim blnAlle As Boolean
Dim ctrElement As Control
Dim Sum As String
arrSpielAuswahl = Array(3, 9, 15, 21, 27, 33) ' 1. Spalte des jeweiligen Spiels
arrTreffer = Array(1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 8) ' Array für die Trefferauswertung
If cbbSpiel <> "" Then
' Schleife über alle Steuerelemente
For Each ctrElement In Me.Controls
' Stuerelement ist eine ComboBox
If TypeName(ctrElement) = "ComboBox" Then
' ComboBox1 - ComboBox5
Select Case ctrElement.Name
Case "ComboBox1", "ComboBox2", "ComboBox3", "ComboBox4", "ComboBox5"
' eine der ComboBoxen enthält keine Auswahl
If ctrElement = "" Then
' Variable auf True setzen und Schleife verlassen
blnAlle = True
Exit For
End If
End Select
End If
Next ctrElement
' alle ComboBoxen haben eine Auswahl
If blnAlle = False Then
lngZeile = Range(ComboBox8.RowSource).Cells(1).Row + ComboBox8.ListIndex
'lngZeile = Range(arrNamen(ComboBox11.ListIndex)).Row + ComboBox8.ListIndex
With Sheets("Beispiel")
If ComboBox8.ListIndex > -1 Then
loS = arrSpielAuswahl(cbbSpiel.ListIndex)
If Application.CountA(.Range(.Cells(lngZeile, loS), .Cells(lngZeile, loS + 5))) > 5 Then
MsgBox "Dieser Teilnehmer hat schon 5 Würfe gespielt."
Exit Sub
Else
.Cells(lngZeile, loS) = arrTreffer(ComboBox1.ListIndex) '1 Wurf vom Spiel
.Cells(lngZeile, loS + 1) = arrTreffer(ComboBox2.ListIndex) '2 Wurf vom Spiel
.Cells(lngZeile, loS + 2) = arrTreffer(ComboBox3.ListIndex) '3 Wurf vom Spiel
.Cells(lngZeile, loS + 3) = arrTreffer(ComboBox4.ListIndex) '4 Wurf vom Spiel
.Cells(lngZeile, loS + 4) = arrTreffer(ComboBox5.ListIndex) '5 Wurf vom Spiel
.Cells(lngZeile, loS + 5) = CDbl(TextBox3) 'Gesamt vom Spiel
[color=#FF0000] Sum = "=SUM(RC[-31],RC[-25],RC[-19],RC[-13],RC[-7],RC[-1])" 'Gesamt vom Siel aus Spalte 8, 14, 20, 26, 32 und 38
.Cells(lngZeile, 39) = Sum[/color]
If IsNumeric(TextBox4) Then .Cells(lngZeile, 40) = .Cells(lngZeile, 40) + CDbl(TextBox4)
If IsNumeric(TextBox5) Then .Cells(lngZeile, 41) = .Cells(lngZeile, 41) + CDbl(TextBox5)
If IsNumeric(TextBox6) Then .Cells(lngZeile, 42) = .Cells(lngZeile, 42) + CDbl(TextBox6)
If IsNumeric(TextBox8) Then .Cells(lngZeile, 43) = .Cells(lngZeile, 43) + CDbl(TextBox8)
UserForm_Initialize
Me.TextBox3 = ""
Me.TextBox4 = ""
Me.TextBox5 = ""
Me.TextBox6 = ""
Me.TextBox8 = ""
End If
Else
MsgBox "Keinen Spieler ausgewählt"
End If
End With
Else
MsgBox "Bitte für alle Würfe einen Wert auswählen"
End If
Else
MsgBox "Bitte ein Spiel auswählen"
End If
End Sub
Danke für die Hilfe :100: