Kako v Excel iskati in vrniti več vrednosti brez dvojnikov?
Včasih boste morda želeli vlookup in vrniti več ujemajočih se vrednosti v eno celico hkrati. Toda, če je v vrnjene celice vnesenih nekaj ponavljajočih se vrednosti, kako lahko prezrete dvojnike in ohranite edinstvene vrednosti le, če vrnete vse ujemajoče se vrednosti, kot je prikazano na sliki zaslona, prikazani v Excelu?
Vlookup in vrnitev več ujemajočih se vrednosti brez dvojnikov z uporabniško določeno funkcijo
Vlookup in vrnitev več ujemajočih se vrednosti brez dvojnikov z uporabniško določeno funkcijo
Naslednja koda VBA vam lahko pomaga vrniti več ujemajočih se vrednosti brez dvojnikov. Naredite to:
1. Držite tipko Alt + F11 tipke za odpiranje Microsoft Visual Basic za aplikacije okno.
2. Kliknite Vstavi > Moduliin prilepite naslednjo kodo v Moduli Okno.
Koda VBA: Vlookup in vrnitev več unikatnih ujemajočih se vrednosti:
Function MultipleLookupNoRept(Lookupvalue As String, LookupRange As Range, ColumnNumber As Integer)
Dim xDic As New Dictionary
Dim xRows As Long
Dim xStr As String
Dim i As Long
On Error Resume Next
xRows = LookupRange.Rows.Count
For i = 1 To xRows
If LookupRange.Columns(1).Cells(i).Value = Lookupvalue Then
xDic.Add LookupRange.Columns(ColumnNumber).Cells(i).Value, ""
End If
Next
xStr = ""
MultipleLookupNoRept = xStr
If xDic.Count > 0 Then
For i = 0 To xDic.Count - 1
xStr = xStr & xDic.Keys(i) & ","
Next
MultipleLookupNoRept = Left(xStr, Len(xStr) - 1)
End If
End Function
3. After inserting the code, then click Tools > References in the opened Microsoft Visual Basic for Applications window, and then, in the popped out References – VBAProject dialog box, check Microsoft Scripting Runtime option in the Available References list box, see screenshot:

4. Then click OK to close the dialog box, save and close the code window, return to the worksheet, and enter this formula: =MultipleLookupNoRept(E2,A2:C17,3) into a blank cell where you want to output the result, press Enter key to get the correct result as you need. See screenshot:

Note: In the above formula, E2 is the criteria that you want to vlookup, A2:C17 is the data range that you want to use, the number 3 is the column number which contains the returned values.
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!
Sort comments by
#25374
This comment was minimized by the moderator on the site
#25375
This comment was minimized by the moderator on the site
Report
#25376
This comment was minimized by the moderator on the site
Report
#25377
This comment was minimized by the moderator on the site
#25782
This comment was minimized by the moderator on the site
#25783
This comment was minimized by the moderator on the site
Report
#27935
This comment was minimized by the moderator on the site
#27936
This comment was minimized by the moderator on the site
Report
#28399
This comment was minimized by the moderator on the site
Report
#29974
This comment was minimized by the moderator on the site
#32177
This comment was minimized by the moderator on the site
#32178
This comment was minimized by the moderator on the site
Report
#32464
This comment was minimized by the moderator on the site
There are no comments posted here yet