Hallo
Erstmal danke für die Hilfe immer wieder toll in diesem Forum
der erste Schritt klappt jetzt sollen natürlich die berechneten Daten auch zurück in die userform(GvW) im einem Label ausgegeben werden.
Auch werden in der Function Zellenbezüge aus der Exceltabelle zur weiteren Berechnung benötigt.
Da aber keine Tabelle vorhanden ist, muss dieser Wert durch den Wert der Combobox ersetzt werden.
Ich hoffe es es nicht gar zu viel verlangt.
Gruß Peter
Hiermal die Function
Die Werte, die berechnetet werden sollen habe ich mal fett markiert.
Function Gehaltsrechner()
With GwV
re4 = .ComboBox18 'Bruttolohn
lzz = .ComboBox19 'Lohnzahlungszeitraum, Monat=2
stkl = .ComboBox20 'Steuerklasse 1 - 6
krv = .ComboBox21 'allgemeine(=0) oder besondere (=1) Lohnsteuertabelle
zkf = .ComboBox22 'Zahl d. Kinderfreibeträge (0, 0.5, 1, 1.5 usw eingeben
kist = .ComboBox23 'Kirchensteuer (0=keine, 8=8%, 9=9%
kv = .ComboBox25 'Krankenversicherung 0=privat, z.B 14,9=14,9%
ost = .ComboBox27 'Ostdeutschland nein=0 ja=1
alter1 = .ComboBox29 'vor 1941 geboren=1, 1941=2, danach==0
jfreib = .ComboBox31 '(Jahres)lohnsteuerfreibetrag
sonstb = .ComboBox32 'Einmalzahlung (wie Weihnachts- und Urlaubsgeld)
jsonstb = .ComboBox33 'Summe schon abgerechneter Einmalzahlungen
sonstbret = sonstb
End With If stkl = 2 And zkf = 0 Then
MsgBox "Bei Steuerklasse II muß ein Kinder-" & Chr(13) & "freibetrag eingetragen sein"
Range("B6").Value = 1
End If
'Achtung: Zellen B9 und B11 + B17 (PflegeV) und B13 (Minijob) werden im Programm angesprochen
If lzz = 2 Then
lzzf = 12
ElseIf lzz = 3 Then
lzzf = 360 / 7
ElseIf lzz = 4 Then
lzzf = 360
Else
lzzf = 1
End If
If stkl = 3 Then
kztab = 2
Else
kztab = 1
End If
jre4 = re4 * lzzf 'Jahreslohn
jre4soz = jre4 'Sozialversicherung Wert retten
If lzzf = 1 Then 'Einmalzahlungen im LZZ Jahr zum Jahreslohn addieren
jre4 = jre4 + sonstb + jsonstb
jre4soz = jre4soz + sonstb + jsonstb
sonstb = 0
jsonstb = 0
End If
kvrett = kv 'KV-Wert retten
'Jahreslohn berechnen ohne Einmalzahlung
jre4 = freibetraege(jre4, alter1, stkl) 'Vorwegabzug des Alterssentlastungsfreibetrages
jre4 = jre4
Steuerberechnung jre4, kztab, krv, stkl, zkf, jre4soz, ost, kv, kist, lzzf, jfreib
For i = 0 To 3
stresult1(i) = stresult(i) 'Werte retten
sozresult1(i) = sozresult(i)
Next
If sonstb > 0 Then 'Jahreslohn mit allen Einmalzahlungen
jre4soz = re4 * lzzf + sonstb + jsonstb 'Sozialversicherung dito
jre4 = re4 * lzzf + sonstb + jsonstb 'Jahreslohn mit Summe der Einmalzahlungen
jre4 = freibetraege(jre4, alter1, stkl) 'wieder Vorwegabzug des Alterssentlastungsfreibetrages
kv = kvrett
Steuerberechnung jre4, kztab, krv, stkl, zkf, jre4soz, ost, kv, kist, lzzf, jfreib
stresultdiff(0) = stresult(0) - stresult1(0) 'auf Einmalzahlungen entfallende Lohnsteuer
For i = 0 To 3
sozresultdiff(i) = sozresult(i) - sozresult1(i) 'Sozialversicherung f. Einmalzahlungen
Next
If jsonstb > 0 And sonstb > 0 Then 'Jahreslohn nur mit schon abgerechneten Einmalzahlungen
jre4 = re4 * lzzf + jsonstb
jre4soz = jre4 'Sozialversicherung dito
jre4 = freibetraege(jre4, alter1, stkl) 'wieder Vorwegabzug des Alterssentlastungsfreibetrages
kv = kvrett
Steuerberechnung jre4, kztab, krv, stkl, zkf, jre4soz, ost, kv, kist, lzzf, jfreib
stresultjahrdiff = stresultdiff(0) - (stresult(0) - stresult1(0)) 'auf aktuelle Einmalzahlung enfallende Lohnsteuer
stresultdiff(0) = stresultjahrdiff
For i = 0 To 3
sozresultdiff1(i) = sozresultdiff(i) - (sozresult(i) - sozresult1(i))
sozresultdiff(i) = sozresultdiff1(i)
Next
End If
stresultdiff(1) = stresultdiff(0) * 0.055 'auf Einmalzahlung enfallender Soli (keine Berücksichtigung von Kinderfreibeträgen)
stresultdiff(2) = stresultdiff(0) * kist * 0.01 'auf Einmalzahlung enfallende KiSt (dito)
End If
'Berechnungswerte für aktuellen Lohn + Einmalzahlung zusammenrechnen und auf Cent abrunden
stresult(0) = Int((Int(stresult1(0)) / lzzf + Int(stresultdiff(0))) * 100) / 100
stresult(1) = Int(((stresult1(1) / lzzf) + stresultdiff(1)) * 100) / 100
stresult(2) = Int(((stresult1(2) / lzzf) + stresultdiff(2)) * 100) / 100
For i = 0 To 3 ' dito für Sozialversicherung, Zwischenwerte dann löschen
sozresult(i) = sozresult1(i) / lzzf + sozresultdiff(i)
stresultdiff(i) = 0
sozresultdiff(i) = 0
Next
Range("B18").Value = stresult(0) 'Steuer im Lohnzahlungszeitraum
Range("B19").Value = stresult(1) 'SolZuschlag
Range("B20").Value = stresult(2) 'Kirchensteuer
Range("B21").Value = Application.Round(sozresult(0), 2) 'RentenV
Range("B22").Value = Application.Round(sozresult(1), 2) 'KrankenV
Range("B23").Value = Application.Round(sozresult(2), 2) 'PflegeV
Range("B24").Value = Application.Round(sozresult(3), 2) 'ArbeitslosenV
belast = Range("B26").Value Range("B27").Value = re4 + sonstbret - belast
End Function
Function Steuerberechnung(jre4, kztab, krv, stkl, zkf, jre4soz, ost, kv, kist, lzzf, jfreib)
vsps = mvsp(jre4, kztab, krv, stkl, 0, lzzf) 'Abzüge für Lohnsteuer berechnen
vspsoli = mvsp(jre4, kztab, krv, stkl, zkf, lzzf) ' Abzüge f. Soli/Kirchensteuer berechnen
jfreib = Int(jfreib * 100) / 100 '(Jahres)lohnsteuerfreibetrag
x = Int((jre4 - (vsps + jfreib)) / kztab)
' MsgBox jre4 & ", " & vsps
ESt x, stkl
st = Int(result * 100 * kztab) / 100
stresult(0) = st
x = Int((jre4 - (vspsoli + jfreib)) / kztab)
ESt x, stkl 'Steuerberechnung nach ggflls Abzug Kinderfreibeträge
stsoli = Int(result) * kztab
result = MathMax(MathMin(0.055 * stsoli, (stsoli - 972 * kztab) * 0.2), 0) ' Soliberechnung
stresult(1) = Int(result * 100) / 100
bk = Int(stsoli * kist) / 100 'Kirchensteuerberechnung
stresult(2) = bk
If krv = 0 Then
sozberech jre4soz, ost, kv, stkl, zkf, lzzf ' Sozialversicherung berechnen
Else 'Werte löschen
For i = 0 To 3
sozresult(i) = 0
Next
End If
End Function
' MathMax/MathMin
Public Function MathMax(value1, value2) As Double
If value1 > value2 Then
MathMax = value1
Else
MathMax = value2
End If
End Function
Public Function MathMin(value1, value2) As Double
If value1
Public Function freibetraege(jre4, alter1, stkl) As Double
BMG = 0
'Werte für Altersenlastung bis 2020
TAB4 = Array(0, 40, 38.4, 36.8, 35.2, 33.6, 32, 30.4, 28.8, 27.2, 25.6, 24, 22.4, 20.8, 19.2, _
17.6, 16)
TAB5 = Array(0, 1900, 1824, 1748, 1672, 1596, 1520, 1444, 1368, 1292, 1216, 1140, 1064, 988, _
912, 836, 760)
If alter1 > 0 Then
BMG = MathMin(Int(TAB4(alter1) * jre4 + 0.9) / 100, TAB5(alter1)) 'auf Cent aufrunden
End If
freibetraege = jre4 - BMG
End Function
' Einkommensteuer für 2008 berechnen
Function ESt(x, stkl)
If stkl
uptab07 x
Else
mst5_6 x
End If
End Function
Function uptab07(x)
y = (x - 7664) / 10000
Z = (x - 12739) / 10000
result = 0
If x > 7664 And x
result = (883.74 * y + 1500) * y
ElseIf x > 12739 And x
result = (228.74 * Z + 2397) * Z + 989
ElseIf x > 52151 And x
result = (0.42 * x - 7914)
ElseIf x > 250000 Then
result = (0.45 * x - 15414) ' Reichensteuer
End If
result = Int(result)
End Function
' Steuer der Steuerklassen 5 und 6 berechnen
Function mst5_6(x)
zzx = x
If zzx > 25812 Then
zx = 25812
up5_6 zx
Else
zx = zzx
up5_6 zx
End If
rett = result
reichenst6 = MathMax(0, zzx - 200000) ' Reichensteueranteil bei StKl 5+6
If reichenst6 > 0 Then
zzx = 200000
End If
result = MathMax(0, (zzx - 25812) * 0.42)
rett = rett + result
zx = 9144
up5_6 zx
rett1 = result
result = MathMax(0, (zzx - 9144) * 0.42)
rett2 = MathMin(rett, rett1 + result)
result = rett2 + reichenst6 * 0.45
End Function
Function up5_6(zx)
x = zx * 1.25
uptab07 (x)
St1 = result
x = zx * 0.75
uptab07 (x)
St2 = result
result = MathMax(Int(zx * 0.15), 2 * (St1 - St2))
End Function
' Versorgungspauschale und sonstige Pauschalen
' sowie Kinderfreibeträge berechnen
Public Function mvsp(jre4, kztab, krv, stkl, zkf, lzzf) As Double
vspf = Array(3068, 1334, 667, 1134)
vspo = 0.2 * jre4
If krv = 0 Then
vspvor = MathMax(0, kztab * vspf(0) - 0.16 * jre4)
vspmax1 = MathMin(kztab * vspf(1), vspo - vspvor)
vspmax2 = MathMin(kztab * vspf(2), (vspo - vspvor - vspmax1) / 2)
vsp = MathMin(vspo, vspvor + vspmax1 + vspmax2)
Else
vsp = MathMin(vspo, vspf(3) * kztab)
End If
vsp = Int(vsp) ' nach PAP 2007 wird die alte Vorsorgepauschale wieder abgerundet (wie 2004) _
' ------------------- neu ab 2005 -----------------------------------------------
If vsp > 0 Then 'Berücksichtigung des Altersseinkünftegesetzes
If jre4 * 0.11 vsp Then ' //Günstigerprüfung
vsp = Int(vsp1 + vhb + 0.99) 'Betrag wird aufgerundet
End If
Else
vhb = 0
vsp1 = 0
vsp = 0
End If
ztabfb = Array(0, 956, 2264, 992, 956, 920, 0)
ztabfb = ztabfb(stkl)
If stkl 4 Then
mvsp = ztabfb
End If
End Function
' Sozialversicherung berechnen
Function sozberech(jre4soz, ost, kv, stkl, zkf, lzzf)
If kv > 19 Then
pkv = kv
kv = 0
Else
pkv = 0
End If
bemesk = MathMin(43200, jre4soz) 'KV Bemessungsgrenze 2008
If ost = 1 Then 'RV Bemessungsgrenzen
rvgrenz = 54000
Else
rvgrenz = 63600
End If
bemesr = MathMin(rvgrenz, jre4soz)
rente = 19.9 / 100
alos = 3.3 / 100
pflege = 1.7 / 100
If Range("B17").Value > 0 Then
pflege = 1.95 / 100
End If
If lzzf = 1 Then
pflege = 1.825 / 100
End If
If Range("B11").Value = 1 Then
pflege = 2.7 / 100
If Range("B17").Value > 0 Then
pflege = 2.95 / 100
End If
If lzzf = 1 Then
pflege = 2.825 / 100
End If
End If
zupflege = 0
If Range("B9").Value = 1 And zkf = 0 Then
zupflege = 0.25 / 100
End If
zukv = 0
If kv > 0 Then
zukv = 0.9 / 100
End If
kv = kv / 100
If kv = 0 Then
bemesk = 0
End If
' Anfang Minijob / Gleitzone(400.01 - 800 Euro) SozVer berechnen ------------------------------
mjzve = 0
If jre4soz 0 And lzzf = 12 Then 'Berechnung
f = 0.7732 'nur auf Monatsbasis
'If Range("B17").value > 0 Then
'f = 0.7682
'End If
mjzve = (f * 4800) + (2 - f) * (jre4soz - 4800)
bemesk = mjzve / 12
mjre4 = jre4soz / 12
If Range("B11").Value = 1 Then
pflege = 1.7 / 100
pflege_ag = 0.7 / 100
If Range("B17").Value = 1 Then
pflege = 1.95 / 100
pflege_ag = 0.95 / 100
End If
Else
If Range("B17").Value = 1 Then
pflege = 1.95 / 100
End If
pflege_ag = pflege
End If
sozresult(0) = Application.WorksheetFunction.Round(bemesk * rente / 2, 2) * 2 - Application.WorksheetFunction.Round(mjre4 * rente / 2, 2)
sozresult(1) = Application.WorksheetFunction.Round((bemesk * kv) / 2, 2) * 2 + Application.WorksheetFunction.Round(bemesk * zukv, 2) - Application.WorksheetFunction.Round(mjre4 * kv / 2, 2)
sozresult(2) = Application.WorksheetFunction.Round(bemesk / 2 * (pflege + zupflege), 2) * 2 - Application.WorksheetFunction.Round(mjre4 * pflege_ag / 2, 2)
sozresult(3) = Application.WorksheetFunction.Round(bemesk * alos / 2, 2) * 2 - Application.WorksheetFunction.Round(mjre4 * alos / 2, 2)
For i = 0 To 3
sozresult(i) = sozresult(i) * lzzf
Next i
If jre4soz
For i = 0 To 3
sozresult(i) = 0
Next
End If
' Ende Minijob / Gleitzone --------------------------------------
Else
sozresult(1) = (bemesk * kv / 2 + bemesk * zukv)
sozresult(2) = (bemesk * pflege / 2 + bemesk * zupflege)
sozresult(0) = (bemesr * rente) / 2
sozresult(3) = (bemesr * alos) / 2
End If
If pkv > 0 Then ' Berechnung Privatversicherungsanteil AN
jw = pkv * lzzf
pkv = Application.WorksheetFunction.Round(MathMin(jw / 2, 3369.6), 2)
If Range("B18").Value = 1 Then
pkv = Application.WorksheetFunction.Round(MathMin(jw / 2, 3423.6), 2)
End If
If Range("B12").Value = 1 Then
pkv = Application.WorksheetFunction.Round(MathMin(jw / 2, 3153.6), 2)
If Range("B18").Value = 1 Then
pkv = Application.WorksheetFunction.Round(MathMin(jw / 2, 3207.6), 2)
End If
End If
pkv_ag = Application.WorksheetFunction.Round(pkv, 2)
sozresult(1) = jw - pkv_ag
sozresult(2) = 0
End If
End Function
Public Function komma(zahlenwert) As Double
such = "."
stelle = InStr(1, zahlenwert, such, vbTextCompare)
If stelle > 0 Then
vorkommawert = Mid(zahlenwert, 1, stelle - 1)
nachkommawert = Mid(zahlenwert, stelle + 1, 2)
zahlenwert = (vorkommawert & "," & nachkommawert) * 1
End If
End Function