AW: VBA rechnet falsch aus
Nepumuk
Hallo Marija,
in der Select - Anweisung für die Entfernung
Function preis(Entf As Integer, Gew As Integer) As Variant
Dim n As Integer, m As Integer, Zeilenoffset As Integer
Select Case Gew
Case Is <= 20
Gew = 20
Case Is <= 100
If Gew / 10 <> Int(Gew / 10) Then Gew = (Int(Gew / 10) + 1) * 10
Case Is <= 550
If Gew / 20 <> Int(Gew / 20) Then Gew = (Int(Gew / 20) + 1) * 20
Case Is <= 1100
If Gew / 50 <> Int(Gew / 50) Then Gew = (Int(Gew / 50) + 1) * 50
Case Is <= 15000
If Gew / 100 <> Int(Gew / 100) Then Gew = (Int(Gew / 100) + 1) * 100
Case Else
preis = "Fehler bei Gewicht"
Exit Function
End Select
Select Case Entf
Case Is <= 30
Entf = 30
Case Is <= 100
If Entf / 10 <> Int(Entf / 10) Then Entf = (Int(Entf / 10) + 1) * 10
Case Is <= 300
If Entf / 20 <> Int(Entf / 20) Then Entf = (Int(Entf / 20) + 1) * 20
Case Is <= 311
Entf = 311
Case Is <= 340
Entf = 340
Case Is <= 500
If Entf / 20 <> Int(Entf / 20) Then Entf = (Int(Entf / 20) + 1) * 20
Case Is <= 700
If Entf / 25 <> Int(Entf / 25) Then Entf = (Int(Entf / 25) + 1) * 25
Case Is <= 1000
If Entf / 50 <> Int(Entf / 50) Then Entf = (Int(Entf / 50) + 1) * 50
Case Else
preis = "Fehler bei Entfernung"
Exit Function
End Select
With Worksheets("Stückguttarif")
For n = 5 To 46
If Entf = .Cells(n, 1).Value Then Zeilenoffset = n - 4: Exit For
Next n
For m = 2 To 177
If Gew = .Cells(4, m).Value Then preis = .Cells(4 + Zeilenoffset, m).Value: Exit For
Next m
End With
End Function
Gruß
Nepumuk