Multiple results using lookup value form 2 column

excel_1317

Board Regular
Joined
Jun 28, 2010
Messages
212
In Below table, Column A has company names and column B has IDs. Column C and Column D contains Lookup Values which i need to lookup in Column B.

Here is a code that needs to be amended so that it takes columns C and D. Presently the code takes values from ONLY from Column C and lookup in Column A. Please HELP....

Code:
Sub ProcessLookUpValues()
  Dim X As Long, Z As Long, Index As Long
  Dim ArrLookUp As Variant, ArrIn As Variant, ArrOut As Variant, Counts As Variant
  Columns("D:G").ClearContents
  ArrLookUp = Range("C2:C" & Cells(Rows.Count, "C").End(xlUp).Row)
  ReDim Counts(1 To UBound(ArrLookUp), 1 To 1)
  ArrIn = Range("A2:B" & Cells(Rows.Count, "A").End(xlUp).Row)
  ReDim ArrOut(1 To UBound(ArrIn) + UBound(ArrLookUp), 1 To 3)
  For Z = 1 To UBound(ArrLookUp)
    For X = 1 To UBound(ArrIn)
      If UCase(ArrIn(X, 1)) Like "*" & UCase(ArrLookUp(Z, 1)) & "*" Then
        Counts(Z, 1) = Counts(Z, 1) + 1
        Index = Index + 1
        ArrOut(Index, 1) = ArrIn(X, 1)
        ArrOut(Index, 2) = ArrIn(X, 2)
        ArrOut(Index, 3) = ArrLookUp(Z, 1)
      End If
    Next
    Index = Index + 1
  Next
  Range("D1:G1") = Array("Count of Lookup Value", "Result 1", "Result 2", "Result 3 (Lookup Value")
  Range("D2:D" & 1 + UBound(ArrLookUp)) = Counts
  Range("E2:G" & UBound(ArrOut)) = ArrOut
End Sub

Sheet1
ABCDEFGH
1Table ArrayCompany IDLookup ValueLookup Value 2Count of Lookup ValueResult 1Result 2Result 3 (Lookup Value 1 and Lookup Value 2)
2ABC1Microsoft5Microsoft corp12Microsoft
3Microsoft corp12Coca3Microsoft8Microsoft
4Raytheon Company35FISHRichardson2Microsoft Corporation9Microsoft
5FGH10FGH2Microsoft6Microsoft
6Microsoft8Raytheon2Microsoft.3Microsoft
7Microsoft Corporation9FOLEYHoag3
8Microsoft6CARLSONGASKEY2Coca11Coca
9Coca11FrancisBozicevic2Coca Cola2Coca
10Microsoft.3Honeywell0Coca Cola.4Coca
11Coca Cola2
12Coca Cola.4FISH & RICHARDSON P.C.45FISH Richardson
13Raytheon25Richardson Fish PC75FISH Richardson
14FOLEY HOAG LLP43
15FISH & RICHARDSON P.C.45FGH10FGH
16BOZICEVIC FIELD & FRANCIS52FGH Inc89FGH
17CARLSON GASKEY & OLDS60
18Foley LLP57Raytheon Company35Raytheon
19Richardson Fish PC75Raytheon25Raytheon
20Richardson PC71
21Field & Francis Bozicevic LLP85
22FGH Inc89FOLEY HOAG LLP43FOLEY Hoag
23Francis Bozicevic LLP90Foley & Hoag13FOLEY Hoag
24GASKEY & OLDS CARLSON92Hoag and Foley14FOLEY Hoag
25Foley & Hoag13
26Hoag and Foley14
27CARLSON GASKEY & OLDS60CARLSON GASKEY
28GASKEY & OLDS CARLSON92CARLSON GASKEY
29
30Field & Francis Bozicevic LLP85Francis Bozicevic
31BOZICEVIC FIELD & FRANCIS52Francis Bozicevic

<thead>
</thead><tbody>
</tbody>
Excel 2010
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.

Forum statistics

Threads
1,215,487
Messages
6,125,073
Members
449,205
Latest member
Healthydogs

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