ich habe neulich einen Beitrag geschrieben bezgl. Zellen färben.
Ich öffne nach Doppelklick eine Userform, in welcher dann in einer Combobox1 ein Zeitraum gewählt wird. Eigentlich funktioniert es, aber Excel kackt immer ab. Woran kann das liegen ? Hier mein Code:
Private Sub CommandButton1_Click()
If ComboBox1.Text = "" Then
MsgBox ("Bitte Entladungstyp auswählen!")
Exit Sub
End If
If ComboBox1.Text = "Entladung1" Then
Range(ActiveCell, ActiveCell.Offset(0, 0)).Interior.Color = Me.CLPre.BackColor
ActiveCell.Value = TextBox1.Value & Chr(10) & TextBox2.Value & Chr(10) & TextBox3.Value & Chr( _
_
10)
Unload UserForm1
Exit Sub
End If
If ComboBox1.Text = "Entladung2" Then
Range(ActiveCell, ActiveCell.Offset(1, 0)).Interior.Color = Me.CLPre.BackColor
Range(ActiveCell, ActiveCell.Offset(1, 0)).Merge
ActiveCell.Value = TextBox1.Value & Chr(10) & TextBox2.Value & Chr(10) & TextBox3.Value & Chr( _
_
10)
With Range(ActiveCell, ActiveCell.Offset(1, 0))
Unload UserForm1
Exit Sub
End With
End If
If ComboBox1.Text = "Entladung3" Then
Range(ActiveCell, ActiveCell.Offset(2, 0)).Interior.Color = Me.CLPre.BackColor
ActiveCell.Value = TextBox1.Value & Chr(10) & TextBox2.Value & Chr(10) & TextBox3.Value & Chr( _
_
10)
With Range(ActiveCell, ActiveCell.Offset(2, 0))
.Merge
End With
Unload UserForm1
Exit Sub
End If
If ComboBox1.Text = "Entladung4" Then
'Zelle Färben
Range(ActiveCell, ActiveCell.Offset(3, 0)).Interior.Color = CLPre.BackColor
'Zellen verbinden
'Texte
ActiveCell.Value = TextBox1.Value & Chr(10) & TextBox2.Value & Chr(10) & TextBox3.Value & Chr( _
_
10)
'Zentriert Breite
With Range(ActiveCell, ActiveCell.Offset(3, 0))
.Merge
End With
Unload UserForm1
Exit Sub
End If
End Sub
Habt ihr eine Idee? Gruß Sven