in nachfolgender Datei ist eine UF die nach Kriterien berechnen soll.
Leider sind die Berechnungen nicht so wie ich es will.
Gruß
Sigi
https://www.herber.de/bbs/user/73080.xlsm
Private Sub ComboBox1_Change()
Dim OPG, Obj, WB As Variant
Dim Ges, Ges1 As Variant
Dim Off As Variant
Dim RGE As Variant
Dim Skonto As Variant
Dim Sich As Variant
Dim Endrow%
Dim KdNr$
Dim wks As Object
Dim I%
On Error Resume Next
For Each Obj In Me.Controls
If TypeName(Obj) = "TextBox" Then
Obj.Value = ""
End If
Next Obj
WB = ActiveWorkbook.Name
Set wks = Workbooks(WB).Worksheets("RGJour")
With wks
Endrow = .Cells(Rows.Count, 1).End(xlUp).Row
KdNr = Me.ComboBox1
OPG = CDbl(OPG)
Ges = CDbl(Ges)
Ges1 = CDbl(Ges1)
Off = CDbl(Off)
RGE = CDbl(RGE)
Skonto = CDbl(Skonto)
Sich = CDbl(Sich)
For I = 2 To Endrow
If .Cells(I, 4) = KdNr _
And .Cells(I, 13) = "offen" Or _
.Cells(I, 4) = KdNr And .Cells(I, 13) = "bezahlt" Or _
.Cells(I, 4) = KdNr And .Cells(I, 13) = "Teilzahlung" Then
OPG = OPG + .Cells(I, 8)
Ges = Ges + .Cells(I, 9)
Ges1 = Ges1 + .Cells(I, 10)
RGE = RGE + .Cells(I, 11)
Skonto = Skonto + .Cells(I, 12)
Off = Off + .Cells(I, 14)
Sich = Sich + .Cells(I, 20)
End If
Next I
End With
OPG = FormatNumber(OPG, 2)
Ges = FormatNumber(Ges, 2)
Ges1 = FormatNumber(Ges1, 2)
RGE = FormatNumber(RGE, 2)
Off = FormatNumber(Off, 2)
Skonto = FormatNumber(Skonto, 2)
Sich = FormatNumber(Sich, 2)
With Me
.TextBox1.Value = OPG
.TextBox2.Value = Ges
.TextBox3.Value = Ges1
.TextBox4.Value = RGE
.TextBox5.Value = Off
.TextBox6.Value = Skonto
.TextBox7.Value = Sich
End With
End Sub