Skip to main content
Topic: Search across columns with this LibreOffice Macro  (Read 21 times) previous topic - next topic

Search across columns with this LibreOffice Macro

    🚀 Ever worked with spreadsheets where first names and last names are split across columns — and the regular Find feature just doesn’t cut it? This macro solves that by searching across multiple columns for full names like Smith Jane, even if they’re split.

    And with a simple `.cmd` installer, setup is just a double-click away.

    Let’s walk through how to install the macro, use it in LibreOffice Calc, and even assign a custom keyboard shortcut like Ctrl+Alt+F for instant access.

    ---



    🛠️ What This Macro Does

    Imagine you have:

    D (Last Name)E (First Name)
    DoeJohn
    SmithJane
    This macro lets you search for full names like Smith Jane — even when they’re split across columns. It scans both columns and highlights matching rows.

    ---

    📦 Installing the Macro with a `.cmd` File

    The `.cmd` installer simplifies everything. It:

    • Copies the macro files to the correct LibreOffice user directory 
    • Places the macro in a trusted location to avoid approval dialogs 
    • Prepares it for immediate use 

    ✅ Steps to Install:

    • Download the macro package 
    • Extract the contents to a folder 
    • Double-click the `.cmd` file — it will: 
      • Copy the Python macro to your LibreOffice Scripts directory 
      • Ensure it’s placed in a trusted location for seamless execution 
    • A `.sh` file is included for Linux users
    • This Macro has been tested on LibreOffice 24.8.7.2 running on Windows 10 64-Bit and LibreOffice 7.4.7.2 running on Debian Bookworm ARM64

    You’ll see a confirmation message once it’s installed.

    ---

    🧪 Using the Macro in LibreOffice Calc

    After installation:

    • Open your spreadsheet in LibreOffice Calc  
    • Run the macro — it will: 
      • Prompt you to enter a search term (e.g. `Jane Smith`) 
      • Search across multiple columns (e.g. D and E) 
      • List the row(s) that match both terms 

    No need to manually filter or sort — just run the macro and let it find the match across columns.

    ---

    🎯 Adding a Keyboard Shortcut (e.g. Ctrl+Alt+F)

    Want to run the macro with a single keystroke? Here’s how:

    • Go to Tools → Customize 
    • Click the Keyboard tab 
    • In the Shortcut Keys list, scroll and select Ctrl+Alt+F 
    • In the Category list, choose LibreOffice Macros 
    • Expand My Macros → MultiColumnSearch → MultiColumnSearch.py and select the macro 
    • Click Modify, then OK 
    Now, anytime you press Ctrl+Alt+F, the macro will run instantly.

    ---

    💡 Why Use a `.cmd` Installer?

    • Fast setup — no manual copying or approval dialogs 
    • Trusted execution — avoids macro security prompts 
    • Reproducible — great for teams or deployment scripts 
    • Customizable — you can bundle validation, logging, or shortcut registration 

    ---

    🧩 Bonus Tip: Make It Discoverable

    You can also add the macro to a custom menu or toolbar for users who prefer clicking over shortcuts. Just go to Tools → Customize → Menus or Toolbars, and add your macro under a friendly label like “Multi-Column Search.”
    ---
    [/list]