Als Antwort auf diesen Beitrag
Hallo,
sorry, da hatte ich vergessen ws in Tabelle2 zu ändern.
Tabelle2.Range("C6") = Tabelle2.Cells(Tabelle2.Cells(Rows.Count, 3).End(xlUp).Row, 3)
Die Zeile musst du vor End Sub einfügen - also so:
Private Sub CommandButton4_Click()
Dim i, j
Dim R As Range
Const cNeuesBlatt As String = "Berechnung"
'Prüfung. Wenn einer "ist nicht numerisch", dann raus
If (Not IsDate(TextBox3)) Or IstNichtNum(TextBox1) Or IstNichtNum(TextBox4) Or IstNichtNum(TextBox5) Or IstNichtNum(TextBox6) Or IstNichtNum(TextBox7) Then Exit Sub
'Es passiert alle auf ActiveSheet
Cells(6, "B") = CDbl(Format(TextBox1, "#,##0.00"))
Cells(7, "C") = CDate(TextBox3)
Application.ScreenUpdating = False
'Wert zum neuen Blatt übertragen
Set R = Blatt_selektieren(cNeuesBlatt).Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).EntireRow 'nächste leere Zeile ermitteln. R ist eine Zeile.
For Each i In Split("C7 C11 C6 C12 C13 C14")
j = j + 1
R.Cells(j) = Range(i).Value 'Cells(1) von einer Zeile in der Spalte A dieser Zeile, 2 B, 3 C, usw.
Next
R.Cells(Columns("L").Column) = CDbl(TextBox7) 'C21
R.Cells(Columns("J").Column) = CDbl(TextBox4) 'C17
R.Cells(Columns("K").Column) = CDbl(TextBox5) 'C18
R.Cells(Columns("I").Column) = CDbl(TextBox6) 'C19
R.Cells(Columns("N").Column) = ComboBox1 'C20
'Fromel einreichten
R.Cells(7).FormulaR1C1 = "=SUM(RC[1]+RC[4]-RC[2])" 'Formel in Spalte G: Gesamtverbrauch per Tag aus EVN & Einspeisung aus PV Anlage
R.Cells(8).FormulaR1C1 = "=(RC3-R[-1]C3)" 'Formel in Spalte H (relative Adressierung)
' =SUM(RC[1]+RC[4])
R.Cells(9).Interior.ColorIndex = 35 'Spalte I
' R.Cells(9).FormulaR1C1 = "=(RC[-1])/24"
R.Cells(13).Formula = "=TEXT(" & R.Cells(1).Address & ",""TTTT"")" 'Formel in Spalte M
'Färbung
R.Interior.Pattern = xlNone
R.Cells(5).Interior.ColorIndex = 36
R.Cells(7).Interior.ColorIndex = 34
R.Cells(9).Interior.ColorIndex = 35
'Abschluss
Range("A2").Select
Application.ScreenUpdating = True
Unload Me '--- Userform schließen
Dim raFund As Range
With ActiveSheet
Set raFund = .Columns(3).Find(What:="*", LookIn:=xlValues, LookAt:=xlWhole, _
searchdirection:=xlPrevious)
If Not raFund Is Nothing Then
Application.Goto .Cells(raFund.Row - 3, 1), True
End If
End With
Set raFund = Nothing
Range("A2").Select
Tabelle2.Range("C6") = Tabelle2.Cells(Tabelle2.Cells(Rows.Count, 3).End(xlUp).Row, 3)
End Sub
Gruß Uwe