How to modify the current macro that finds a pair of data in a column to return with the value in a different column?

On the attached spreadsheet I have a macro that will search for a pair of text listed in cells “G2:G3” and return with True or False.  I need it to find the pair and return with the value in column “A” in the same row that the value in “G2” portion on the pair was found in.
Pair-Function.xlsm
kbay808Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

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.

byundtMechanical EngineerCommented:
Here is a user-defined function that will search column C for two successive values and then return a value from column A. You use it with a worksheet formula like:
=Pairs2(G2,G3,C:C,A:A)
Function Pairs2(strFirst As String, strSecond As String, rngSearch As Range, rngReturn As Range) As Variant
Dim i As Long, n As Long
Dim v As Variant
Dim rng As Range
Set rng = Intersect(rngSearch, rngSearch.Worksheet.UsedRange)
n = rng.Rows.Count
v = ""
For i = 1 To n
    If LCase(rng.Cells(i, 1).Value) = LCase(strFirst) Then
        v = rngReturn.EntireColumn.Cells(rng.Cells(i, 1).Row).Value
    ElseIf LCase(rng.Cells(i, 1).Value) = LCase(strSecond) Then
        If v <> "" Then
            Exit For
        ElseIf rng.Cells(i, 1).Value <> "" Then
            v = ""
        End If
    End If
Next
Pairs2 = v
End Function

Open in new window

Pair-FunctionQ28643310.xlsm
0

Experts Exchange Solution brought to you by

Your issues matter to us.

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

Start your 7-day free trial
kbay808Author Commented:
That worked great!  Thank you very much.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.