Question

Below, please find a screenshot that will provide some context for my question.

enter image description here

The above is a modified version of output from a reporting tool used by my company. This report is spit out in Excel 2003 format and I will be manipulating it in Excel2010. I cannot change the format of the output.

My issues with the above are twofold. First, as far as I can tell, the app that generates the report uses nonbreaking spaces everywhere. So simple MATCH statements on something like "Not Blue" will oftentimes return an N/A because I'm searching using a "normal" space between "Not" and "Blue". The other issue is that I cannot figure out how to do a SUMIFS using criteria from the first three columns (to total all Data 1 values where I have Level 1/Blue/Green as my criteria, for example). The cells in columns 1 and 2 are coming over as merged cells and I'd have to manually unmerge them and then copy down the appropriate cell value. This would be painful.

I am hoping there is some way to get around these limitations so that I can write SUMIF formulas (or INDEX/MATCH or SUMPRODUCT or any other summing/matching formulas) relatively easily against the format being spit out by the report, without having to majorly modify the output format. My goal is to set up a standard calculations page which would do lookups against the report spit out by my company's application. To simplify end-user interaction, I want to be able to have them just copy/paste the output from the application into a sheet of my processing tool, which would then figure out the various totals I need.

I am perfectly willing to explore VBA as well as formula-based solutions.

Was it helpful?

Solution

To sum Data1 (D2:D9) based on the column of merged cells (B2:B9) showing "Not Blue", and replacing the non-breaking spaces with spaces, you could try this:

=SUMPRODUCT((LOOKUP(ROW(B2:B9),ROW(B2:B9)/(B2:B9<>""),TRIM(SUBSTITUTE(B2:B9,CHAR(160)," ")))="Not Blue")*D2:D9)

The LOOKUP(.) part of the formula evaluates to:

{"Blue";"Blue";"Blue";"Not Blue";"Not Blue";"Not Blue";"No Answer";"No Answer;"No Answer"}

Additional conditions can be added for other columns of merged cells by replicating this part of the formula and changing the references. For example, you could use this approach to find Data1+Data2+ Data3 for the conditions (Level 1,Not Blue, Red):

=SUMPRODUCT((LOOKUP(.)="Level1")*(LOOKUP(.)="Not Blue")*(C2:C9="Red")*D2:F9)

where (LOOKUP(.)="Not Blue") is contained in the first formula above

and (LOOKUP(.)="Level1") is the same but with A2:A9 in place of B2:B9.

OTHER TIPS

lori_m, I modified your formula as below and this seems to be working:

=SUMPRODUCT(
--(LOOKUP(ROW($A$7:$A$43),ROW($A$7:$A$43)/($A$7:$A$43<>""),
TRIM(SUBSTITUTE($A$7:$A$43,CHAR(160)," ")))="Level 2"),D$7:D$43)

What I can't figure out is why I was originally only getting the top level merged cell value when I used your original formula. I'm sure it was because I mis-transposed something. But in any case, thank you so much for your help.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top