von Stephan » So, 19.07.2020 12:42
per Formel ist das nicht möglich, da Formeln grundsätzlich nichts kopieren. Das es in den mitgelieferten Makros ein passendes Makro gibt glaube ich kaum, man wird also Eines selbst erstellen müssen.
z.B. kann man das Kopieren mit Makrorekorder aufzeichnen und dann das Makro etwas ergäzen und dem EReignis Inhalt geändert des Tabellenblattes zuweiussen.
z.B.:
Code: Alles auswählen
Dim na
sub Main(x)
If na = 1 Then Exit Sub
If x.CellAddress.Row = 8 And x.CellAddress.Column = 2 Then
na = 1
rem ----------------------------------------------------------------------
rem define variables
dim document as object
dim dispatcher as object
rem ----------------------------------------------------------------------
rem get access to the document
document = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
rem ----------------------------------------------------------------------
dim args1(0) as new com.sun.star.beans.PropertyValue
args1(0).Name = "ToPoint"
args1(0).Value = "$A$23:$H$32"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args1())
rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:Copy", "", 0, Array())
rem ----------------------------------------------------------------------
dim args3(0) as new com.sun.star.beans.PropertyValue
args3(0).Name = "ToPoint"
anzahl = ThisComponent.CurrentController.ActiveSheet.getCellRangeByName("C9").Value
If anzahl > 1 Then
z = 23
Do While anzahl > 0
z = z + 11
args3(0).Value = "$A$" & z
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args3())
rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:Paste", "", 0, Array())
anzahl = anzahl - 1
Loop
End If
End If
na = 0
end sub
Gruß
Stephan
- Dateianhänge
-
- Tabelle_mit_Makro.ods
- (16.56 KiB) 65-mal heruntergeladen
per Formel ist das nicht möglich, da Formeln grundsätzlich nichts kopieren. Das es in den mitgelieferten Makros ein passendes Makro gibt glaube ich kaum, man wird also Eines selbst erstellen müssen.
z.B. kann man das Kopieren mit Makrorekorder aufzeichnen und dann das Makro etwas ergäzen und dem EReignis Inhalt geändert des Tabellenblattes zuweiussen.
z.B.:
[code]Dim na
sub Main(x)
If na = 1 Then Exit Sub
If x.CellAddress.Row = 8 And x.CellAddress.Column = 2 Then
na = 1
rem ----------------------------------------------------------------------
rem define variables
dim document as object
dim dispatcher as object
rem ----------------------------------------------------------------------
rem get access to the document
document = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
rem ----------------------------------------------------------------------
dim args1(0) as new com.sun.star.beans.PropertyValue
args1(0).Name = "ToPoint"
args1(0).Value = "$A$23:$H$32"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args1())
rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:Copy", "", 0, Array())
rem ----------------------------------------------------------------------
dim args3(0) as new com.sun.star.beans.PropertyValue
args3(0).Name = "ToPoint"
anzahl = ThisComponent.CurrentController.ActiveSheet.getCellRangeByName("C9").Value
If anzahl > 1 Then
z = 23
Do While anzahl > 0
z = z + 11
args3(0).Value = "$A$" & z
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args3())
rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:Paste", "", 0, Array())
anzahl = anzahl - 1
Loop
End If
End If
na = 0
end sub [/code]
Gruß
Stephan