asked
2012-07-20 07:01:26 +0200
DV88 33 ● 2 ● 3 ● 8 This is a bit tricky to describe, but here goes nothing. I'm trying to write a formula to display the contents of certain cells from a multi-column, multi-row range in an ordered, comma-separated list. It's probably easier to illustrate this than describe it, really:
A B C
1 Name1 5 3
2 Name2 12 8
3 Name3 3 3
4 Name4 -2 -2
5 Name5 8 5
6 Name6 5 5
7 Name7 2 2
8 Name8 0 0
9 Name9 9 4
Ok, that's basically what it's like, except...bigger (7 columns by 30 rows, but only 3 columns are relevant for this).
What I'm trying to do is get the formula, which would output into a single cell, to scan those rows, and where the number in B and C doesn't match up (B would always be higher than C in this case), display "A B" (including the space), and separate the entries with a comma and space, so that it would look like this: "Name1 5, Name2 12, Name5 8, Name9 4".
I figured out how to do it very clumsily, with =IF(B1=C1,"",A1&" "&B1)&IF(SUM(B1:B$9)=SUM(C1:C$9),"",", ")) among others, but all of them have the problem of needing to add every row with addition &s (replacing the = at the front of each with & and sticking it on after). That would be fine, since the table size won't ever change, but I'm running into error 512 (30 rows, remember - it adds up fast) and I'm almost certain there's a better way to do this, a more elegant way, but I can't figure it out...any help would be hugely appreciated!
I think that without a macro - with standard functions of the application only - you don't decide this problem. (I would be happy if I was wrong)
JohnSUN ( 2012-07-20 13:59:21 +0200 )editDo you really need to do every step in Calc? I suppose it would be much easier to break up the task in smaller sub-tasks. For example, filtering the rows where B > C is quite easy; adding another column for every row having name and B value is easy, too. Concatenating may be done in an extra step...
tohuwawohu ( 2012-07-20 14:35:31 +0200 )edit..., maybe outside calc (exporting the resulting table as csv and modifying it in writer or any text editor, or using unix tools like
tohuwawohu ( 2012-07-20 14:38:03 +0200 )editsedmay be possible solutions). I agree with @JohnSUN that this is very hard to solve just using standard Calc functions.@JohnSUN If I can do it with a macro that'd be fine, if it's contained in the program and I can embed it into that file. I have no experience with macros, though - do you have a suggestion of where I should go to learn that?
DV88 ( 2012-07-21 00:57:09 +0200 )edit@tohuwawohu It does need to be done in Calc, sadly - it's part of a series of documents that all need to have the same format. If I absolutely have to do it in multiple steps I can, but I would really, really like to avoid that if at all possible and have it all go to the one cell.
DV88 ( 2012-07-21 00:59:12 +0200 )edit