Die Tabelle (nicht von mir erstellt) enthält "Fälle", die nur aus einer Zeile bestehen, und solche, in denen in einigen Spalten mehrere Zeilen mit Daten gefüllt sind, die zusammen gehören. Das Feld in Spalte A geht jeweils über den ganzen Fall (mal 2, mal 7 Zeilen).
Ich muss die Tabelle nun sortierbar machen.
Dazu will ich
1. in den Fällen Spalten mit mehreren gefüllten Zeilen die entsprechenden Felder ZUSAMMENFÜHREN und dabei die Daten der unteren Zeilen in die oberste übernehmen (das Menü ZUSAMMENFÜHREN bietet das als erste Option an).

- Zwischenablage_07-06-2025_01.jpg (40.12 KiB) 233 mal betrachtet
2. DANN die Felder wieder trennen, so das nur noch 1 gefüllte Zeile (mit allen Informationen aus der Spalte nun in dem dieser Zeile) und darunter entsprechend Leerzeilen entstehen, die sich später "wegsortieren".
Das kann man ganz gut programmieren. ABER: Immer an der Stelle, wo der MERGE aufgerufen wird, kommt das oben gezeigte Dialogfeld, in dem die Option gewählt werden muss, dass der Inhalt nach oben bewegt werden soll.
Inzwischen sieht das so aus:
Code: Alles auswählen
sub verb5
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 -------------------
oZelladresse=ThisComponent.CurrentSelection.CellAddress
row1=oZelladresse.Row+1
'MsgBox ("Selected: "+row1)
rem ----------------------------------------------------------------------
dim args1(1) as new com.sun.star.beans.PropertyValue
args1(0).Name = "By"
args1(0).Value = 1
args1(1).Name = "Sel"
args1(1).Value = false
dispatcher.executeDispatch(document, ".uno:GoDown", "", 0, args1())
rem -------------------
oZelladresse=ThisComponent.CurrentSelection.CellAddress
row2=oZelladresse.Row
'MsgBox ("Selected: "+row2)
rem -------------------
rowdiff=row2-row1
'MsgBox ("Difference: "+rowdiff)
rem ----------------------------------------------------------------------
dim args2(1) as new com.sun.star.beans.PropertyValue
args2(0).Name = "By"
args2(0).Value = 1
args2(1).Name = "Sel"
args2(1).Value = false
dispatcher.executeDispatch(document, ".uno:GoUp", "", 0, args2())
rem ----------------------------------------------------------------------
dim args3(0) as new com.sun.star.beans.PropertyValue
args3(0).Name = "By"
args3(0).Value = 1
dispatcher.executeDispatch(document, ".uno:GoRightSel", "", 0, args3())
rem ----------------------------------------------------------------------
dim args4(0) as new com.sun.star.beans.PropertyValue
args4(0).Name = "By"
args4(0).Value = 1
dispatcher.executeDispatch(document, ".uno:GoRightSel", "", 0, args4())
rem ----------------------------------------------------------------------
dim args5(0) as new com.sun.star.beans.PropertyValue
args5(0).Name = "By"
args5(0).Value = 1
dispatcher.executeDispatch(document, ".uno:GoRightSel", "", 0, args5())
rem ----------------------------------------------------------------------
dim args6(0) as new com.sun.star.beans.PropertyValue
args6(0).Name = "By"
args6(0).Value = 1
dispatcher.executeDispatch(document, ".uno:GoRightSel", "", 0, args6())
rem ----------------------------------------------------------------------
dim args7(0) as new com.sun.star.beans.PropertyValue
args7(0).Name = "By"
args7(0).Value = 1
dispatcher.executeDispatch(document, ".uno:GoRightSel", "", 0, args7())
rem ----------------------------------------------------------------------
dim args8(0) as new com.sun.star.beans.PropertyValue
args8(0).Name = "By"
args8(0).Value = 1
dispatcher.executeDispatch(document, ".uno:GoRightSel", "", 0, args8())
rem ----------------------------------------------------------------------
dim args9(0) as new com.sun.star.beans.PropertyValue
args9(0).Name = "By"
args9(0).Value = 1
dispatcher.executeDispatch(document, ".uno:GoRightSel", "", 0, args9())
rem ----------------------------------------------------------------------
dim args10(0) as new com.sun.star.beans.PropertyValue
args10(0).Name = "By"
args10(0).Value = 1
dispatcher.executeDispatch(document, ".uno:GoRightSel", "", 0, args10())
rem ----------------------------------------------------------------------
dim args11(0) as new com.sun.star.beans.PropertyValue
args11(0).Name = "By"
args11(0).Value = 1
dispatcher.executeDispatch(document, ".uno:GoRightSel", "", 0, args11())
rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:SplitCell", "", 0, Array())
rem ----------------------------------------------------------------------
dim args13(1) as new com.sun.star.beans.PropertyValue
args13(0).Name = "By"
args13(0).Value = 1
args13(1).Name = "Sel"
args13(1).Value = false
dispatcher.executeDispatch(document, ".uno:GoRight", "", 0, args13())
rem ----------------------------------------------------------------------
dim args14(1) as new com.sun.star.beans.PropertyValue
args14(0).Name = "By"
args14(0).Value = 1
args14(1).Name = "Sel"
args14(1).Value = false
dispatcher.executeDispatch(document, ".uno:GoRight", "", 0, args14())
rem ----------------------------------------------------------------------
dim args15(1) as new com.sun.star.beans.PropertyValue
args15(0).Name = "By"
args15(0).Value = 1
args15(1).Name = "Sel"
args15(1).Value = false
dispatcher.executeDispatch(document, ".uno:GoRight", "", 0, args15())
rem ----------------------------------------------------------------------
dim args16(1) as new com.sun.star.beans.PropertyValue
args16(0).Name = "By"
args16(0).Value = 1
args16(1).Name = "Sel"
args16(1).Value = false
dispatcher.executeDispatch(document, ".uno:GoRight", "", 0, args16())
rem ----------------------------------------------------------------------
dim args17(1) as new com.sun.star.beans.PropertyValue
args17(0).Name = "By"
args17(0).Value = 1
args17(1).Name = "Sel"
args17(1).Value = false
dispatcher.executeDispatch(document, ".uno:GoRight", "", 0, args17())
rem ----------------------------------------------------------------------
dim args18(1) as new com.sun.star.beans.PropertyValue
args18(0).Name = "By"
args18(0).Value = 1
args18(1).Name = "Sel"
args18(1).Value = false
dispatcher.executeDispatch(document, ".uno:GoRight", "", 0, args18())
rem ----------------------------------------------------------------------
dim args19(1) as new com.sun.star.beans.PropertyValue
args19(0).Name = "By"
args19(0).Value = 1
args19(1).Name = "Sel"
args19(1).Value = false
dispatcher.executeDispatch(document, ".uno:GoRight", "", 0, args19())
rem ----------------------------------------------------------------------
dim args20(1) as new com.sun.star.beans.PropertyValue
args20(0).Name = "By"
args20(0).Value = 1
args20(1).Name = "Sel"
args20(1).Value = false
dispatcher.executeDispatch(document, ".uno:GoRight", "", 0, args20())
rem ----------------------------------------------------------------------
dim args21(1) as new com.sun.star.beans.PropertyValue
args21(0).Name = "By"
args21(0).Value = 1
args21(1).Name = "Sel"
args21(1).Value = false
dispatcher.executeDispatch(document, ".uno:GoRight", "", 0, args21())
rem ----------------------------------------------------------------------
dim args22(1) as new com.sun.star.beans.PropertyValue
args22(0).Name = "By"
args22(0).Value = 1
args22(1).Name = "Sel"
args22(1).Value = false
dispatcher.executeDispatch(document, ".uno:GoRight", "", 0, args22())
rem ----------------------------------------------------------------------
dim args23(0) as new com.sun.star.beans.PropertyValue
args23(0).Name = "By"
args23(0).Value = 1
dispatcher.executeDispatch(document, ".uno:GoRightSel", "", 0, args23())
rem ----------------------------------------------------------------------
dim args24(0) as new com.sun.star.beans.PropertyValue
args24(0).Name = "By"
args24(0).Value = rowdiff
dispatcher.executeDispatch(document, ".uno:GoDownSel", "", 0, args24())
rem ----------------------------------------------------------------------
rem dispatcher.executeDispatch(document, ".uno:MergeCells", "", 0, Array())
rem ----------------------------------------------------------------------
dim args26(0) as new com.sun.star.beans.PropertyValue
args26(0).Name = "MoveContents"
args26(0).Value = false
dispatcher.executeDispatch(document, ".uno:MergeCells", "", 0, args26())
rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:SplitCell", "", 0, Array())
end sub
Im vorletzten Block (uno:MergeCells) fehlt mir die Möglichkeit der Auswahl bzw. der Untderdrückung des Dialogs mit Wahl der ersten Option. Der letzte Block (uno:SplitCell) wird so gar nicht mehr ausgeführt.