What is the command for that.
How to vlookup to return multiple values in one cell in Excel?
Normally, in Excel, when you use the VLOOKUP function, if there are multiple values to match the criteria, you just can get the first one. But, sometimes, you want to return all the corresponding values which meet the criteria into one cell as following screenshot shown, how could you solve it?
Vlookup to return multiple values in one cell with User Defined Function
Vlookup to return multiple values in one cell with kutools for Excel
Vlookup to return multiple corresponding values in one single cell:
With Kutools for Excel’s Advanced Combine Rows utiltiy, you can quickly combine multiple duplicate rows into one record based on key columns, and it also can apply some calculations such as sum, average, count and so on for other columns.
Kutools for Excel: with more than 200 handy Excel add-ins, free to try with no limitation in 60 days. Download and free trial Now! |
Vlookup to return multiple values in one cell with User Defined Function
The traditional VLOOKUP function may not help you to solve this problem, but, I will create a User Defined Function for you to deal with this task. Please do as follows:
1. Activate your worksheet which you want to vlookup multiple values into one cell.
2. Hold down the ALT + F11 keys, and it opens the Microsoft Visual Basic for Applications window.
3. Click Insert > Module, and paste the following code in the Module Window.
VBA code: Vlookup to return multiple values in one cell
Function MYVLOOKUP(pValue As String, pWorkRng As Range, pIndex As Long) 'Update 20150310 Dim rng As Range Dim xResult As String xResult = "" For Each rng In pWorkRng If rng = pValue Then xResult = xResult & " " & rng.Offset(0, pIndex - 1) End If Next MYVLOOKUP = xResult End Function
4. Then save and close this code, go back to the worksheet, and enter this formula: =myvlookup(E6,$A$2:$C$15,2) into a specific blank cell where you want to place the result, then press Enter key to get all the corresponding values in one cell that you want, see screenshot:
Note:
In the above formula: E6 is the value which you want to return its relative information, A2:C15 is the data range you use, the number 2 indicates the column number that your matched value is returned.
Vlookup to return multiple values in one cell with kutools for Excel
If you have our Kutools for Excel, with its Advanced Combine Rows feature, you can quickly merge or combine the rows based on the same value and do some calculations.
Kutools for Excel : with more than 300 handy Excel add-ins, free to try with no limitation in 60 days. |
After installing Kutools for Excel, please do as follows:
1. Select the data range that you want to combine one column data based on another data.
2. Click Kutools > Merge & Split > Advanced Combine Rows, see screenshot:
3. In the popped out dialog box, click the key column to be combined based on, and then click Primary Key. Then click another column that you want to combine its data based on the key column, and click Combine to choose one separator for separating the combined data, see screenshot:
4. Then click OK button, and you will get the following results:
Click to know more about this Advanced Combine Rows feature.
Download and free trial Kutools for Excel Now !
Demo: Vlookup to return multiple values in one cell with Kutools for Excel
Kutools for Excel: with more than 200 handy Excel add-ins, free to try with no limitation in 30 days. Download and free trial Now!
Related articles:
How to vlookup next largest value in Excel?
How to vlookup in two dimensional table in Excel?
How to vlookup to another workbook?
The Best Office Productivity Tools
Kutools for Excel Solves Most of Your Problems, and Increases Your Productivity by 80%
- Reuse: Quickly insert complex formulas, charts and anything that you have used before; Encrypt Cells with password; Create Mailing List and send emails...
- Super Formula Bar (easily edit multiple lines of text and formula); Reading Layout (easily read and edit large numbers of cells); Paste to Filtered Range...
- Merge Cells/Rows/Columns without losing Data; Split Cells Content; Combine Duplicate Rows/Columns... Prevent Duplicate Cells; Compare Ranges...
- Select Duplicate or Unique Rows; Select Blank Rows (all cells are empty); Super Find and Fuzzy Find in Many Workbooks; Random Select...
- Exact Copy Multiple Cells without changing formula reference; Auto Create References to Multiple Sheets; Insert Bullets, Check Boxes and more...
- Extract Text, Add Text, Remove by Position, Remove Space; Create and Print Paging Subtotals; Convert Between Cells Content and Comments...
- Super Filter (save and apply filter schemes to other sheets); Advanced Sort by month/week/day, frequency and more; Special Filter by bold, italic...
- Combine Workbooks and WorkSheets; Merge Tables based on key columns; Split Data into Multiple Sheets; Batch Convert xls, xlsx and PDF...
- More than 300 powerful features. Supports Office/Excel 2007-2019 and 365. Supports all languages. Easy deploying in your enterprise or organization. Full features 30-day free trial. 60-day money back guarantee.
Office Tab Brings Tabbed interface to Office, and Make Your Work Much Easier
- Enable tabbed editing and reading in Word, Excel, PowerPoint, Publisher, Access, Visio and Project.
- Open and create multiple documents in new tabs of the same window, rather than in new windows.
- Increases your productivity by 50%, and reduces hundreds of mouse clicks for you every day!