Date: prev next · Thread: first prev next last
2026 Archives by date, by thread · List index


Und hier eine Makrolösung. Funktioniert, sofern die Felder in den Tabellen wirklich alle mit Daten gefüllt sind, also z.B. nicht irgendwo Vornamen fehlen usw.

---------------

Sub SheetsZusammenSortieren
DIM oRange AS OBJECT, oDoc AS OBJECT, oSheet AS OBJECT, oSheetTarget AS OBJECT
        DIM k AS INTEGER, n AS INTEGER, m AS INTEGER
        DIM stHeader AS STRING
        DIM arHeader(3)
        Dim oSortFields(0) As New com.sun.star.table.TableSortField
        Dim oSortProps(2) As New com.sun.star.beans.PropertyValue
        oDoc = thisComponent
        oSheetTarget = oDoc.sheets(3)
        m = 0
        FOR i = 0 TO 2
                oSheet = oDoc.sheets(i)
                k = 0
                DO
                        oCell = oSheet.getCellByPosition(k,0)
                        stHeader = oCell.String
                        SELECT CASE stHeader
                                CASE "CodeVN"
                                        arHeader(0) = k
                                CASE "CodeNN"
                                        arHeader(1) = k
                                CASE "Nachname"
                                        arHeader(2) = k
                                CASE "Vorname"
                                        arHeader(3) = k
                        END SELECT
                        k = k + 1
                LOOP UNTIL stHeader = ""
                FOR n = 0 TO 3
                        k = 1
                        DO
                                oCell = oSheet.getCellByPosition(arHeader(n),k)
                                stContent = oCell.String
                                oCellTarget = oSheetTarget.getCellByPosition(n,k+m)
                                oCellTarget.String = stContent
                                k = k + 1       
                        LOOP UNTIL stContent = ""
                NEXT
                m = m + k-2
        NEXT
        oRange = oSheetTarget.getCellRangeByName("A1:D" & m + 1)
        oSortFields(0).Field = 0
        oSortFields(0).IsAscending = True
        oSortProps(0).Name = "SortFields"
        oSortProps(0).Value = oSortFields()
        oSortProps(1).Name = "SortColumns"
    oSortProps(1).Value = False
    oSortProps(2).Name = "ContainsHeader"
    oSortProps(2).Value = True
        oRange.sort(oSortProps())
End Sub

--------------------

Gruß

Robert
--
Homepage: https://www.familiegrosskopf.de/robert

--
Liste abmelden mit E-Mail an: users+unsubscribe@de.libreoffice.org
Probleme? https://de.libreoffice.org/hilfe-kontakt/mailing-listen/abmeldung-liste/
Tipps zu Listenmails: https://wiki.documentfoundation.org/Netiquette/de
Listenarchiv: https://listarchives.libreoffice.org/de/users/
Datenschutzerklärung: https://www.documentfoundation.org/privacy

Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.