Ask Your Question

Copy/paste all rows found in "Find All" Keyword Search - Libreoffice Calc

asked 2019-05-05 03:21:39 +0100

Choices gravatar image

updated 2020-09-03 13:38:41 +0100

Alex Kemp gravatar image

I have a large spreadsheet file which I am searching for certain keywords. So I do "Find All".

I get e.g. 100 hits. I want to copy all the rows containing the keyword and paste into another sheet.

How do I select and then copy/paste those rows?


edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted

answered 2019-05-05 09:42:32 +0100

karolus gravatar image

updated 2019-05-05 20:19:25 +0100

In the case the hits are all in the same column you can do the task by:
> Data > Filter > Standardfilter (…) + Options: [x]regular Expression [x]Filteroutput to: "other Sheet.…"


If your hits spread widely over several columns, you can try your search up to find all and run then:

from uno import createUnoStruct as create_struct

def copyrows():
    source_address = create_struct("")
    target_address = create_struct("")
    doc = XSCRIPTCONTEXT.getDocument()
    sheet = doc.CurrentController.ActiveSheet
    descriptions = doc.CurrentSelection.RowDescriptions
    rows = { entry.split()[1] for entry in descriptions }
    rows = sorted(map(int,rows))

    for i, row in enumerate(rows):        

        source_address.StartRow = source_address.EndRow = row-1
        source_address.EndColumn = 1023

        target_address.Sheet = 1
        target_address.Row = i

        sheet.copyRange(target_address, source_address)

its python, you have to copy this SourceCode into:

Keep care to have an empty sheet behind the sheet youre working on.

edit flag offensive delete link more


OK thanks, I'll have to check this out. So if I search for my keyword in one column only, which I can do, I can then follow your steps? I'll report back. Cheers

Choices gravatar imageChoices ( 2019-05-05 13:23:10 +0100 )edit
Login/Signup to Answer

Question Tools

1 follower


Asked: 2019-05-05 03:21:39 +0100

Seen: 648 times

Last updated: May 05 '19