Interestingly enough, collapsing the rows first and then the columns will produce a different result
Your question is best and easiest done via a script. The full code is here:
The basic steps are:
- row collapse the grid, using:
var r = row.filter((a) => { return a && a != ''});
- column collapsing = transpose, row collapse it, and then transpose again
There are a bunch of nitty-gritty details that you are better consulting the code. The lack of commenting there is only because I write self-describing code :-))) ,, NOT
HOW TO USE THIS
- Tools - Code Editor
- Copy and Paste the code into code.gs
- Four custom functions are now available (*)
- Example usage can be found when you do View - Show Formula
(*) You can change the names to your liking. As of now, they are:
- rowCollapse()
- colCollapse()
- rowColCollapse()
- colRowCollapse()
It does look like you only need colCollapse. I misread your question and that's why came up with 4 functions (though 2 of them as core tasks are required, as described above)
USAGE,, just like Sheet built-in functions, is case-insensitive, of course.