IF + AND (or vlookup formula?)

dangorka

New Member
Joined
Feb 23, 2018
Messages
11
Hi guys,


I need a help with my spreadsheet


I have data populated by scraping VBA macro in range J2:S9


Table in range A1:G9 should automatically "process" with formulas data according to my needs. Each row represents separate game. Under each game there will be either one (the same) or two (different) lines available


For example for third row (game id 2) line is the same (0.5). Therefore cell B3 should display this line (0.5) and in next cell (C3) display the highest value from respective columns =MAX(K3, N3, Q3). Cell D3 should do the same but for an away team so =MAX(L3, O3, R3) (in this case for cell C2 correct number to display is 0.93 and for cell D2 it's 1). Cells E2, F2 and G2 in this scenario should be auto-populated with "n/a" text.


However it gets tricky for rows like second row (game id 1). In this case line A is the same as line B but different than line C, therefore for each line maximum values have to be treated separately (formula must also deal with similar situations when for example Line A is the same as line C but different than line B) therefore cell B2 should display one unique line (0/0.5) cell C2 and D2 should display the highest respective value (so either K2 or N20 for C2 and L2 or O2 for D2). Then another line should be auto-populated by formula in cell E2 (0.5 from cell P2) and therefore F2 will be simply a value from cell R2 and H2=R2


I hope it does make sense, attaching photo of the sheet below (as a new user I can't attach files it seems)

sFrLPAI.png
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
Welcome to the MrExcel board!

(as a new user I can't attach files it seems)
Nobody can attach files but you can post screen shots that data can be copied from (like mine here) which will more likely attract helpers as we then don't have to manually type data. See my signature block below for further details.

Do these formulas, copied down, do what you want?
If not please post sample data with expected results & any further explanation.


Book1
ABCDEFGHIJKLMNOPQRS
1Game idFirst lineHome 1st lineAway 1st lineSecond lineHome 2nd lineAway 2nd lineLine AHome AAway ALine BHome BAway BLine CHome CAway CGame id
210/0.50.851.110.51.070.830/0.50.821.110/0.50.851.080.51.070.831
320.50.9310.50.9210.50.930.990.50.920.982
430/0.50.861.110/0.50.821.110/0.50.861.060/0.50.821.063
540/0.50.741.260/0.50.711.260/0.50.741.220/0.50.71.214
650.50.871.07-0.50.841.040.50.851.070.50.871.05-0.50.841.045
760/0.51.090.850/0.51.070.850/0.51.090.840/0.51.060.826
870/-0.50.711.280/-0.50.711.260/-0.50.71.280/-0.50.681.257
980/-0.50.831.10/-0.50.831.090/-0.50.831.10/-0.50.811.078
dangorka
Cell Formulas
RangeFormula
B2=J2
C2=AGGREGATE(14,6,K2:Q2/((LEFT($K$1:$Q$1,4)="Home")*(J2:P2=$B2)),1)
D2=AGGREGATE(14,6,L2:R2/((LEFT($L$1:$R$1,4)="Away")*(J2:P2=$B2)),1)
E2=IF(M2=B2,IF(P2=B2,"",P2),M2)
F2=IF(E2="","",AGGREGATE(14,6,K2:Q2/((LEFT($K$1:$Q$1,4)="Home")*(J2:P2=$E2)),1))
G2=IF(E2="","",AGGREGATE(14,6,L2:R2/((LEFT($L$1:$R$1,4)="Away")*(J2:P2=$E2)),1))
 
Upvote 0
Yes! That's exactly what I needed, many, many thanks for such a quick response! :) interesting formula I didn't have a clue about before!
 
Upvote 0
Yes! That's exactly what I needed, many, many thanks for such a quick response! :) interesting formula I didn't have a clue about before!
You are very welcome. Glad it helped. :)
 
Upvote 0

Forum statistics

Threads
1,223,727
Messages
6,174,148
Members
452,547
Latest member
Schilling

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top