Wpis z mikrobloga

Cześć, mam problem z prostym kodem w Visual Basic w Excelu.
Ma on mnożyć i dodawać wartości różnych komórek do komórki E11 zależnie od jej wartości.

Private Sub CommandButton1_Click()
Dim KOSZT As Integer
KOSZT = Range("C11").Value

If KOSZT < 100 Then
Range("E11").Value = KOSZT * Range("D4").Value
Else
If 100 <= KOSZT <= 1000 Then
Range("E11").Value = (KOSZT * Range("D5").Value) + Range("E5").Value
Else
If 1000 <= KOSZT <= 5000 Then
Range("E11").Value = (KOSZT * Range("D6").Value) + Range("E6").Value
Else
If 5000 < KOSZT Then
Range("E11").Value = (KOSZT * Range("D7").Value) + Range("E7").Value
End If

End Sub

Kod dodałem przez "Insert command button(activex controll) > view code"
Normalnie nie programuję w VBA, więc na 90% składnia.

halp.

#programowanie #vba
  • 6