How to filter cells based on value in current cell?

I’d like to add a keyboard shortcut to LibreOffice calc that applies a simple filter for the value in current cell; i.e. in the same manner as if I’d applied autofilter and selected the value from the dropdown.

I’m guessing that it can be done using a macro, but have very limited experience with libreoffice macros. I tried “record macro”, but couldn’t get it to work. Any help or tips are appreciated.

“I tried “record macro”, but couldn’t get it to work.”
Please explain what you mean. Macro recording doesn’work? Or it works but you cannot run just recorded macro? Or you don’t know how to create a keyboard shortcut for your macro? Or something else?..

@Vitaly I tried to record while setting up a simple filter, but the recording didn’t pick up what I was doing. I also tried with auto-filter, but got the same result.

quite old question, sorry, don’t think OP is still waiting, but similar request may occur once and a while …

i had the same wish, had a easy solution in ex$el long time ago and tried to construct similar for LO … it was ‘not so easy’ …

try to use code below, should be quite near to OP request,

disclaimer: provided ‘as is’ as a sample for own work, without any warranty expressed or implied to the extend permitted by law,

known shortcomings:
zero resp. “” values, empty cells,
numeric vs. alphanumeric filtering, esp. for cols with mixed datatypes, or e.g. text ‘03’ vs. number 3 formatted with ‘two leading zeroes’,
errors in column adjustment for files saved and reloaded with autofilter active,
some old stuff in code from attempts to manage difficult datatypes, kept as reference, will remove once the changes have proved successful for some time,

try to improve code, i’d be happy,

my ‘system’: keyboard shortcuts, alt-F1 to toggle Filter on / off, alt-F2 to filter / unfilter actual column with value of actual cell, alt-F3 to step forward, shift-alt-F3 to step backward in the list of values … fine …

i provide the macro as an attachement because this editor consequently messes up my code formatting in an attempt to save whitespace?

sub_datasurfer_macro.doc