# Return the intersection value from a matrix in Excel

I would like a formula in Column  Risk Exposure (E4) to return the value from a matrix (RiskExposuretable) based on the intersection of the value in Column (Probability (C4)) and the value in Column (Impact (D4).
Test-Return-Intersection.xlsx
###### Who is Participating?

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Older than dirtCommented:
The attached workbook contains a User Defined Formula called 'Intersection' in cell E4. Note that it's dependent on the sheet's structure. In other words if for example the location of the Risk Exposure Table changes then the UDF will need to be changed.
28689965.xlsm
Author Commented:
Can you make it reference the "RiskExposureTable" instead of being hard coded to reference to row 18 and column 4 in this line?
Intersection = Cells(I + 18, P + 4)
Commented:
You can use this formula in cell E4...

=INDEX(RiskExposureTable, MATCH(D4, Impact, 0)+1, MATCH(SUBSTITUTE(C4, "~", "~~"), Probability, 0)+2)

Wayne

Experts Exchange Solution brought to you by

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Older than dirtCommented:
``````Function Intersection(rngP As Range, rngI As Range) As String
Dim lngEntry As Long
Dim I As Integer
Dim P As Integer
Dim rngRET As Range

Set rngRET = Cells.Find(What:="Risk Exposure Table", After:=ActiveCell, LookIn:= _
xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:= _
xlNext, MatchCase:=False, SearchFormat:=False)

For lngEntry = 1 To Range("Impact").Cells(1, 1).Row + Range("Impact").Rows.Count - 1
If Range("Impact").Cells(lngEntry, 1) = rngI Then
I = lngEntry
Exit For
End If
Next
For lngEntry = 1 To Range("Probability").Cells(1, 1).Row + Range("Probability").Columns.Count - 1
If Range("Probability").Cells(1, lngEntry) = rngP Then
P = lngEntry
Exit For
End If
Next

Intersection = Cells(I + rngRET.Row + 3, P + rngRET.Column + 1)
End Function
``````
Older than dirtCommented:
BTW aren't at least your pink, 2 and 3, column values backward? In other words under 2, as the Impact increases, shouldn't it go from Manageable to Threatening and not the opposite as you have it?
Author Commented:
You are right, the risk values are backwards, that I leave that up to the author.
Author Commented:
Both options were acceptable and I thank you for the feedback.
Older than dirtCommented:
You're welcome and I'm glad I was able to help.

In my profile you'll find links to some articles I've written that may interest you.
Marty - MVP 2009 to 2015