Re: Makro möglich? Addieren auf Knopfdruck
Verfasst: Fr, 27.02.2009 20:09
Hallo!
Ich habe dir mal ein Beispiel programmiert, wie man so was machen kann.
1. Summieren
2. Abziehen
Gruß
Charly
Ich habe dir mal ein Beispiel programmiert, wie man so was machen kann.
1. Summieren
Code: Alles auswählen
Sub Summieren()
Dok = ThisComponent
Controller = Dok.getCurrentController
Blatt = Controller.ActiveSheet
WertP5 = Blatt.getCellRangeByName("P5").value
WertQ5 = Blatt.getCellRangeByName("Q5").value
WertX1 = Blatt.getCellRangeByName("X1").value
WertX2 = Blatt.getCellRangeByName("X2").value
WertP5 = WertP5 + WertX1
WertQ5 = WertQ5 + WertX2
If WertP5< 120 then
Blatt.getCellRangeByName("P5").value = WertP5
else
Blatt.getCellRangeByName("P5").value = 120
end if
If WertQ5< 120 then
Blatt.getCellRangeByName("Q5").value = WertQ5
else
Blatt.getCellRangeByName("Q5").value = 120
end if
End Sub
Code: Alles auswählen
Sub Abziehen()
Dok = ThisComponent
Controller = Dok.getCurrentController
Blatt = Controller.ActiveSheet
WertP5 = Blatt.getCellRangeByName("P5").value
WertQ5 = Blatt.getCellRangeByName("Q5").value
WertX1 = Blatt.getCellRangeByName("X1").value
WertX2 = Blatt.getCellRangeByName("X2").value
WertP5 = WertP5 - WertX1
WertQ5 = WertQ5 - WertX2
If WertP5>= 0 then
Blatt.getCellRangeByName("P5").value = WertP5
else
Blatt.getCellRangeByName("P5").value = 0
end if
If WertQ5>= 0 then
Blatt.getCellRangeByName("Q5").value = WertQ5
else
Blatt.getCellRangeByName("Q5").value = 0
end if
End Sub
Charly