I was searching around on internet and playing around in Excel 2010, but could'nt really find an answer.
For the sake of cleanliness I made an abstract, but the real file is a lot bigger.
In another sheet I want to look up text A and get the output of the relative time (Column B). However, if row 2 extends up to Column Z (or even more) I want all the output times return the same value, as visible for A, B and C in the picture below.
Column D will probably be gone/hidden when I fix the conditional formatting. It's also possible that 'K' comes before 'H' though, so the values may not be in order (as visible for F, G and H
This is the first problem. I tried solving it with INDEX-MATCH, but for an unknown number of rows and columns that's pretty tedious. There are also many blanks, so I need to build safes for that too.
The formula for only 6 columns would look like this:
=IFERROR(INDEX(T0.02!$B$1:$B$100;IF(ISNA(MATCH($A3;T0.02!$D$1:$D$100;0))=FALSE;MATCH($A3;T0.02!$D$1:$D$100;0);IF(ISNA(MATCH($A3;T0.02!$E$1:$E$100;0))=FALSE;MATCH($A3;T0.02!$E$1:$E$100;0);IF(ISNA(MATCH($A3;T0.02!$F$1:$F$100;0))=FALSE;MATCH($A3;T0.02!$F$1:$F$100;0);IF(ISNA(MATCH($A3;T0.02!$G$1:$G$100;0))=FALSE;MATCH($A3;T0.02!$G$1:$G$100;0);IF(ISNA(MATCH($A3;T0.02!$H$1:$H$100;0))=FALSE;MATCH($A3;T0.02!$H$1:$H$100;0);IF(ISNA(MATCH($A3;T0.02!$I$1:$I$100;0))=FALSE;MATCH($A3;T0.02!$I$1:$I$100;0);"")))))));"")
The main question for me is: is it possible to do it an easier way in Excel, or is there a way doing it with VBA. I'm not really 'good' with VBA so I would really need help with that then.