Ask Your Question
0

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

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

Choices gravatar image

updated 2019-05-05 03:22:12 +0200

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?

Thanks

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
0

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

karolus gravatar image

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

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.…"

EDIṬ̣:

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("com.sun.star.table.CellRangeAddress")
    target_address = create_struct("com.sun.star.table.CellAddress")
    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:
$(your_User_Configfolder)/Scripts/python/<some-file-name>.py

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

edit flag offensive delete link more

Comments

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 +0200 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

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

Seen: 58 times

Last updated: May 05