Ask Your Question
0

Macro for filtering empty cells and pasing result to another location

asked 2018-11-19 10:33:26 +0100

Kruno gravatar image

updated 2018-11-20 10:20:47 +0100

Hi,

In Calc I have a list of people and keep track who is showing up for every working day of a month. Managed to use formulas to dynamically locate desired column based on current month and date, so I'm presented with needed information, but polluted with blank cells.

I need to copy that over to Writer for making a report and problem is that empty cells get copied too so I need to manually clean Writer document on daily bases.

Where I could start to learn macro so I can get desired range, filter out empty cells and paste only non-empty cells to a different location on same sheet.

Need information and explanations about particular functions and methods needed to be used. Big HowTos or Getting started Guides won't do me much good as then I need to learn it all before I can get a grip about what I need to know for this particular task. I would rather start from what I need to know right now and expand from there.

Hopefully this makes (at least some) sense.

Thanks

edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted
2

answered 2018-11-19 23:10:38 +0100

Hello @Kruno

Please find Demo spreadsheet attached. The file contents macro in Basic, which shows you the principles of getting the desired range, creating filter descriptor and conditions and then copying the result in another place on the sheet. The code shows the basics and I also tried to comment each step to describe it as much as possible. As I am not aware of the real structure of your data, you definitely will need to adopt these lines for your task, feel free to ask help!

P.S. Here is a good topic about filtering data using formulas. Maybe we can try to help you to modify them for your needs. And the suggestion by @PhLo is also good - it takes only a few seconds to reset and reapply AutoFilter, while cleaning up Writer document is definitely longer.

edit flag offensive delete link more

Comments

Thank you very much! I did some macro programming in Google Sheets but they documented everything very nicely. It's very hard to find needed information when it comes to LO. I'm looking at your spreadsheet right now and demo does what I need :) I'll inspect how your macro is done and report back this evening or next morning to provide feedback and accept the answer. Thank you and @PhLo.

Kruno gravatar imageKruno ( 2018-11-20 10:20:29 +0100 )edit

Your example works only if content in column A is direct input, but my 'column A' holds information that's result of array formula. Think script is not able to interpret that. Think that adding functionality to first hard-copy range from column A to column B and then filter by column B would do the trick. But thanks, you gave me what I needed, rest is for another question and for me to investigate further.

Kruno gravatar imageKruno ( 2018-11-20 19:32:27 +0100 )edit

Recorded a Macro that copies content that's result of array formula to helper column and modified your script to use that at starting point - solved! Thanks!

Kruno gravatar imageKruno ( 2018-11-20 20:13:15 +0100 )edit

You are welcome, @Kruno !

SM_Riga gravatar imageSM_Riga ( 2018-11-20 21:45:58 +0100 )edit
0

answered 2018-11-19 11:15:13 +0100

PhLo gravatar image

updated 2018-11-19 11:18:15 +0100

Your situation might be more complex than the auto-filter can answer, especially if it involves multiple columns of connected info. But if not, it could help you or someone else.

Auto Filter tool in Calc. With the top cell of your desired range selected (usually a column heading above the values), click this tool

image description

This is what I started with, notice the blanks between the letters:

image description

If you click on the Auto Filter tool, you should see a dropdown on the column heading. Click it and uncheck "Empty" to make empty rows disappear temporarily. You can remove the filter to restore the blanks later.

image description

Now all the blanks are gone (hidden, not deleted). If you select all the filled-in values and copy/paste them, the blanks should not be copied along with.

image description

edit flag offensive delete link more

Comments

Thank you for the input, but filter is a no-go. Content is static range of dynamically populated cells - they change every day within the range and filtering is not showing the change. I would need to apply filter every day, which is the same as cleaning up Writer document. What I actually want is copy of that range but without empty cells. Maybe can be done with formulas INDEX, MATCH, ROW, MIN, MAX... don't know. Some did it without macro, but I'm not able do modify formulas to get what I need

Kruno gravatar imageKruno ( 2018-11-19 17:46:43 +0100 )edit

I kinda figured you had good reason to ask specifically about macros. I have learned a bit about them in the last month but mostly in the context of Base, not Calc. Sorry I'm not much else help. I also had difficulty finding good documentation. There are macro experts on this forum. Hopefully one of them will chime in for you.

PhLo gravatar imagePhLo ( 2018-11-19 18:05:02 +0100 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2018-11-19 10:33:26 +0100

Seen: 51 times

Last updated: Nov 20 '18