This is a a bit of a complex problem that i really would like to sort out but I'm not quite sure the best way to handle it. Let me first explain the problem. In Sheet1, I have a list of substitutions. For example, in the calculation I want to perform, I want 1 to be interpreted as 0.8, 2 to be interpreted as 0.5, and 3 to be interpreted as 0.1. Sheet1 is very simple and is literally no more complex than what is shown.
Sheet1:
A, B
1, 0.8
2, 0.5
3, 0.1
In Sheet2, the data I want to process is found in alternating columns. Below is an example, however the real Sheet2 is more extensive in size.
A, B, C, D, E, F
1, x, 2, x, 1, x
2, x, 1, x, 2, x
I want a formula (which would be placed in Sheet2 where the x's are now) that looks at the row (actually it's C1:ZZ1) and counts every other column using the substituted values found in Sheet1. In this example, I want the first x in the first row to produce:
0.8+0.5+0.8=2.1
If that weren't complicated enough, I actually need to do some additional math (I need the Sheet1 value for the cell to the left to be divided by the 2.1). In this case it would be 0.8/(0.8+0.5+0.8)=0.38 . Likewise, the second x in the first column would be 0.5/(0.8+0.5+0.8)=0.24 and so on.
The more I get into it, the more complicated it seems to get. One of the issues that I can't get around is that I need to be able to expand the number of columns in the future without breaking the formula (that's why I suggested going all the way to ZZ1). I was thinking INDIRECT potentially would allow me just to look for values relative to the cells location (to the left) and allow me to use a single formula for all x's above but it produced a mind numbing effect and I promptly stopped.
An idea I've tossed around without success: using COUNTIF to count the number of 1's 2's and 3's in a row (odd columns only), multiplying by the respective values in Sheet1 and adding those products together (then dividing the contents of the lefthand cell by that sum that was created). This would avoid having to use vlookup which was my first instinct but I couldn't get it to play friendly with other functions.
Anyway, I'm at the tearing out my hair stage - I would certainly appreciate some help if anyone can help me solve this puzzle.
Bookmarks