Note: The other languages of the website are Google-translated. Back to English
Logáil isteach  \/ 
x
or
x
Cláraigh  \/ 
x

or

Conas luachanna iolracha a bhreathnú agus a thabhairt ar ais gan dúbailtí in Excel? 

Uaireanta, b’fhéidir gur mhaith leat luachanna iolracha comhoiriúnaithe a vlookup agus a chur ar ais i gcill aonair ag an am céanna. Ach, má tá roinnt luachanna arís agus arís eile daonra sna cealla ar ais, conas a d’fhéadfá neamhaird a dhéanamh de na dúblacha agus gan na luachanna uathúla a choinneáil ach na luachanna meaitseála uile a thabhairt ar ais mar a leanas an pictiúr a thaispeántar in Excel?

faigh doc luachanna uathúla iolracha 1

Vlookup agus seol luachanna iolracha meaitseála gan dúbailtí trí Fheidhm Sainithe Úsáideora a úsáid


Vlookup agus seol luachanna iolracha meaitseála gan dúbailtí trí Fheidhm Sainithe Úsáideora a úsáid

Is féidir leis an gcód VBA seo a leanas cabhrú leat luachanna meaitseála iolracha a thabhairt ar ais gan dúbailtí, déan mar seo é le do thoil:

1. Coinnigh síos an Alt + F11 eochracha a oscailt Microsoft Visual Basic d’Fheidhmchláir fhuinneog.

2. Cliceáil Ionsáigh > Modúil, agus greamaigh an cód seo a leanas sa Modúil Fuinneog.

Cód VBA: Vlookup agus seol luachanna iolracha comhoiriúnaithe ar ais:

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. Tar éis duit an cód a chur isteach, ansin cliceáil uirlisí > tagairtí san oscailt Microsoft Visual Basic d’Fheidhmchláir fuinneog, agus ansin, sa popped amach Tagairtí - VBAProject bosca dialóige, seiceáil Microsoft Scripting Runtime rogha sa Tagairtí atá ar Fáil bosca liosta, féach an scáileán:

faigh doc luachanna uathúla iolracha 2

4. Ansin cliceáil OK chun an bosca dialóige a dhúnadh, an fhuinneog cód a shábháil agus a dhúnadh, filleadh ar an mbileog oibre, agus an fhoirmle seo a iontráil: =MultipleLookupNoRept(E2,A2:C17,3) isteach i gcill bhán inar mian leat an toradh a aschur, brúigh Iontráil eochair chun an toradh ceart a fháil de réir mar is gá duit. Féach an pictiúr:

faigh doc luachanna uathúla iolracha 3

nótaí: San fhoirmle thuas, E2 na critéir ar mhaith leat a vlookup, A2: C17 an raon sonraí a theastaíonn uait a úsáid, an uimhir 3 is í uimhir an cholúin ina bhfuil na luachanna ar ais.


Na hUirlisí Táirgiúlachta Oifige is Fearr

Réitíonn Kutools for Excel an chuid is mó de do chuid Fadhbanna, agus Méadaíonn sé do Tháirgiúlacht 80%

  • Athúsáid: Cuir isteach go tapa foirmlí casta, cairteacha agus aon rud a d'úsáid tú roimhe seo; Cealla a Chriptiú le pasfhocal; Cruthaigh Liosta Ríomhphoist agus seol ríomhphoist ...
  • Barra Foirmle Super (cuir línte iolracha téacs agus foirmle in eagar go héasca); Leagan Amach Léitheoireachta (líon mór cealla a léamh agus a chur in eagar go héasca); Greamaigh go dtí an Raon Scagtha...
  • Cumaisc Cealla / Sraitheanna / Colúin gan Sonraí a chailleadh; Ábhar Cealla Scoilt; Comhcheangail Sraitheanna / Colúin Dúblacha... Cill Dúblach a Chosc; Déan comparáid idir Ranganna...
  • Roghnaigh Dúblach nó Uathúil Sraitheanna; Roghnaigh Blank Rows (tá na cealla uile folamh); Aimsigh Super agus Fuzzy Aimsigh i go leor Leabhar Oibre; Roghnaigh go randamach ...
  • Cóip Díreach Cealla Il gan tagairt fhoirmle a athrú; Tagairtí Cruthaigh Auto chuig Bileoga Il; Cuir Urchair isteach, Boscaí Seiceála agus go leor eile ...
  • Sliocht Téacs, Cuir Téacs leis, Bain de réir Poist, Bain Spás; Subtotals Paging a chruthú agus a phriontáil; Tiontaigh Idir Ábhar Cealla agus Tráchtanna...
  • Scagaire Super (scéimeanna scagaire a shábháil agus a chur i bhfeidhm ar bhileoga eile); Ard-Sórtáil de réir míosa / seachtaine / lae, minicíocht agus níos mó; Scagaire Speisialta le cló trom, iodálach ...
  • Comhcheangail Leabhair Oibre agus Bileoga Oibre; Cumaisc Táblaí bunaithe ar eochaircholúin; Roinn Sonraí i Ilbhileoga; Baisc Tiontaigh xls, xlsx agus PDF...
  • Níos mó ná 300 gné chumhachtach. Tacaíochtaí Office / Excel 2007-2019 agus 365. Tacaíonn sé le gach teanga. Imscaradh éasca i d’fhiontar nó d’eagraíocht. Gnéithe iomlána triail saor in aisce 30 lá. Ráthaíocht ar ais airgid 60 lá.
cluaisín kte 201905

Tugann Tab Oifige comhéadan Tabbed chuig Office, agus Déan Do Obair i bhfad Níos Éasca

  • Cumasaigh eagarthóireacht agus léamh tabbed i Word, Excel, PowerPoint, Foilsitheoir, Rochtain, Visio agus Tionscadal.
  • Oscail agus cruthaigh cáipéisí iolracha i gcluaisíní nua den fhuinneog chéanna, seachas i bhfuinneoga nua.
  • Méadaíonn do tháirgiúlacht 50%, agus laghdaíonn sé na céadta cad a tharlaíonn nuair luch duit gach lá!
bun officetab
Say something here...
symbols left.
You are guest
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.
  • To post as a guest, your comment is unpublished.
    Drew · 1 years ago
    This is great! How would I adapt this to not add null values to the dictionary? I've tried adding the bold below, but the final string is still returning with ,"", instances.


    xRows = LookupRange.Rows.Count
    For i = 1 To xRows
    If LookupRange.Columns(1).Cells(i).Value = Lookupvalue And Not IsEmpty(LookupRange.Columns(1).Cells(i).Value) Then
    xDic.Add LookupRange.Columns(ColumnNumber).Cells(i).Value, ""
    End If
    Next

    Thanks,
  • To post as a guest, your comment is unpublished.
    Jame · 1 years ago
    Hello , I did as u told and it great but it still havent solve one of my problem , what happen when u unique value in each month ? =MultipleLookupNoRept(E2,A2:C17,3) , i try to E2&1 for January but it not working
    • To post as a guest, your comment is unpublished.
      skyyang · 1 years ago
      Hi, Jame,
      Could you give your problem as a screenshot here, so that i can understand your requires?
  • To post as a guest, your comment is unpublished.
    srikanth · 2 years ago
    hi,
    while the time of lot value multivlooks my worksheet got hang.is there any other ways to multivlookupwithoutrepeation????

    and also i used on new desktop also its getting hang only...

    my data value is around 10,000 rows
  • To post as a guest, your comment is unpublished.
    rasike001 · 2 years ago
    Hi

    I wanted to create a list in a table from this instead of all results in one cell. So I have used a formula similar below (what you have suggested)

    =LOOKUP(2, 1/((COUNTIF($E$1:E1, $B$2:$B$12)=0)*($D$2=$A$2:$A$12)), $B$2:$B$12)

    However, this is taking a long time to process from a large set of data.
    Is there any alternative method to process this faster?
    Thanks again
    Rasike
  • To post as a guest, your comment is unpublished.
    Imre · 2 years ago
    xStr = xStr & xDic.Keys(I) & "," to be this: xStr = xStr & xDic.Keys(I) & ", "

    Is there a way to replace "," with in-cell ALT+ENTER, so that the results will be in the same cell but on different lines? Do I need to introduce additional VBA module for that and combine them?

    Also, this code is quite slow when looping over huge tables. Anyone knows any faster solutions?
    • To post as a guest, your comment is unpublished.
      skyyang · 2 years ago
      Hi, Imre,
      To separate the result values by Alt + Enter keys, please apply the following User Defined Function:

      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) & Chr(10) + Chr(13)
      Next
      MultipleLookupNoRept = Left(xStr, Len(xStr) - 1)
      End If
      Debug.Print xStr
      End Function

      And then do with the above steps in this article, at last, after entering the formula, you should click Wrap Text under the Home tab.
  • To post as a guest, your comment is unpublished.
    Demetre · 3 years ago
    Is there a way to add a space in between the multiple values retrieved in the results without introducing a comma at the end of the list? For example your result above would show as: "Emily, James, Daisy, Gary" instead of like this: "Emily,James,Daisy,Gary"

    I tried to edit this portion of the VBA code: xStr = xStr & xDic.Keys(I) & "," to be this: xStr = xStr & xDic.Keys(I) & ", "

    That did add the space in between the values, but it also added a comma after the last value. "Emily, James, Daisy, Gary,"

    Is there a way to make it work with the space but without the extra comma after the last value?
    • To post as a guest, your comment is unpublished.
      skyyang · 3 years ago
      Hello, Demetre,
      Use the space to separate the values, you just need to change the vba code:
      from xStr = xStr & xDic.Keys(i) & "," to be this: xStr = xStr & xDic.Keys(i) & " "

      Please try it.
  • To post as a guest, your comment is unpublished.
    Tom · 3 years ago
    what if I wanted to create a list in a table from this instead of all results in one cell?
    • To post as a guest, your comment is unpublished.
      skyyang · 3 years ago
      Hello, Tom,
      If you want to extract the unique values in a list of cells instead of one cell, the following formula may help you:

      =LOOKUP(2, 1/((COUNTIF($E$1:E1, $B$2:$B$12)=0)*($D$2=$A$2:$A$12)), $B$2:$B$12)

      Please try it.
      • To post as a guest, your comment is unpublished.
        clifford · 3 months ago
        Hi skyyang what if you want the result as a column?
      • To post as a guest, your comment is unpublished.
        rasike001 · 2 years ago
        Hi Skyyang,

        Thank you very much for this formula.
        This works for me. However, it is taking a long time to process from a large set of data.
        Can we modify this formula to work this bit faster?
        Thanks again
        Rasike