Warum funktioniert der Code nicht?
Laufzeitfehler 1004
Private Sub CommandButton2_Click()
Dim Tbb As Integer
Dim TbbH As Integer
Dim lastRow As Long
Dim z As Integer
Dim AZ As Integer
z = TextBox1.Value
TbbH = ActiveSheet.Index
AZ = ActiveCell.Row
If OptionButton1.Value = True Then Tbb = 1
If OptionButton2.Value = True Then Tbb = 2
If OptionButton3.Value = True Then Tbb = 3
If OptionButton4.Value = True Then Tbb = 4
If OptionButton5.Value = True Then Tbb = 5
If OptionButton6.Value = True Then Tbb = 6
If OptionButton7.Value = True Then Tbb = 7
If OptionButton8.Value = True Then Tbb = 8
With Application
.Calculation = xlCalculationManual
.ScreenUpdating = False
End With
Sheets(Tbb).Unprotect
lastRow = Sheets(Tbb).Cells(Rows.Count, 4).End(xlUp).Row
Sheets(Tbb).Range(Cells(lastRow + 1, 4), Cells(lastRow + z + 1, 15)) = Sheets(TbbH).Range(Cells(AZ, 4), Cells(AZ + z, 15)).Value2
Sheets(Tbb).Range(Cells(lastRow + 1, 6), Cells(lastRow + 1 + z, 6)) = ""
Unload Me
Sheets(Tbb).protect
With Application
.Calculation = xlCalculationAutomatic
.ScreenUpdating = True
End With
Sheets(Tbb).Activate
End Sub
Im voraus vielen Dank
Ulf