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

or

Conas liosta anuas a chruthú le roghnúcháin nó luachanna iolracha in Excel?

De réir réamhshocraithe, ní féidir leat ach mír amháin in aghaidh an ama a roghnú ó liosta anuas bailíochtaithe sonraí in Excel. Conas ilroghnuithe a dhéanamh ón liosta anuas mar a thaispeántar thíos an scáileán? Is féidir leis na modhanna san alt seo cabhrú leat an fhadhb a réiteach.

Cruthaigh liosta anuas le ilroghnuithe le cód VBA
Cruthaigh liosta anuas go héasca le ilroghnuithe le huirlis iontach

Tuilleadh teagaisc don liosta anuas ...


Cruthaigh liosta anuas le ilroghnuithe le cód VBA

Is féidir leat an cód VBA thíos a chur i bhfeidhm chun ilroghnuithe a dhéanamh ón liosta anuas i mbileog oibre in Excel. Déan mar a leanas le do thoil.

1. Oscail an bhileog oibre atá leagtha síos agat ar liosta anuas bailíochtaithe sonraí, cliceáil ar dheis ar an táb bileog agus roghnaigh Féach an cód ón roghchlár comhthéacs.

2. Sa Microsoft Visual Basic d’Fheidhmchláir fuinneog, cóipeáil an cód VBA thíos i bhfuinneog an chóid. Féach an pictiúr:

Cód VBA: liosta anuas le ilroghnuithe

Private Sub Worksheet_Change(ByVal Target As Range)
    'Updated by Extendoffice 2019/11/13
    Dim xRng As Range
    Dim xValue1 As String
    Dim xValue2 As String
    If Target.Count > 1 Then Exit Sub
    On Error Resume Next
    Set xRng = Cells.SpecialCells(xlCellTypeAllValidation)
    If xRng Is Nothing Then Exit Sub
    Application.EnableEvents = False
    If Not Application.Intersect(Target, xRng) Is Nothing Then
        xValue2 = Target.Value
        Application.Undo
        xValue1 = Target.Value
        Target.Value = xValue2
        If xValue1 <> "" Then
            If xValue2 <> "" Then
                If xValue1 = xValue2 Or _
                   InStr(1, xValue1, ", " & xValue2) Or _
                   InStr(1, xValue1, xValue2 & ",") Then
                    Target.Value = xValue1
                Else
                    Target.Value = xValue1 & ", " & xValue2
                End If
            End If
        End If
    End If
    Application.EnableEvents = True
End Sub

3. Brúigh an Eile + Q eochracha chun an Microsoft Visual Basic d’Fheidhmchláir fhuinneog.

Anois is féidir leat míreanna éagsúla a roghnú ón liosta anuas sa bhileog oibre reatha.

Nótaí:

  • 1. Ní cheadaítear luachanna dúblacha ar an liosta anuas.
  • 2. Agus an leabhar oibre á dhúnadh, bainfear an cód VBA go huathoibríoch, agus ní féidir an ilroghnú a úsáid níos mó. Sábháil an leabhar oibre mar Leabhar Oibre Macra-Chumasaithe Excel d’fhonn an cód a choinneáil ag obair sa todhchaí.

Cruthaigh liosta anuas go héasca le ilroghnuithe le huirlis iontach

Seo a mhol go hard an Liosta anuas ilroghnacha gné de Kutools le haghaidh Excel duitse. Leis an ngné seo, is féidir leat go leor míreanna a roghnú go furasta ón liosta anuas i raon sonraithe, bileog oibre reatha, leabhar oibre reatha nó gach leabhar oibre oscailte de réir mar is gá duit.

Roimh iarratas a dhéanamh Kutools le haghaidh Excel, Le do thoil é a íoslódáil agus a shuiteáil ar dtús.

1. cliceáil Kutools > Liosta anuas > Liosta anuas ilroghnacha > Socruithe. Féach an pictiúr:

2. Sa Socruithe Liosta anuas Ilroghnacha bosca dialóige, cumraigh mar a leanas le do thoil.

  • 2.1) Sonraigh an raon feidhme feidhmeach sa Cuir iarratas isteach alt. Sa chás seo, roghnaím Bileog oibre reatha ó na Raon feidhme Sonraithe liosta anuas;
  • 2.2) Sa Treo Téacs roinn, roghnaigh treo téacs bunaithe ar do chuid riachtanas;
  • 2.3) Sa deighilteoir bosca, iontráil teorantóir a úsáidfidh tú chun na luachanna iolracha a scaradh;
  • 2.4) Seiceáil an Ná cuir dúbailtí leis bosca sa Roghanna roinn mura dteastaíonn uait dúbailtí a dhéanamh i gcealla liosta anuas;
  • 2.5) Cliceáil ar an OK cnaipe. Féach an pictiúr:

3. Cliceáil le do thoil Kutools > Liosta anuas > Liosta anuas ilroghnacha chun an ghné a chumasú.

Anois is féidir leat míreanna iomadúla a roghnú ón liosta anuas sa bhileog oibre reatha nó aon scóip atá sonraithe agat i gcéim 2.

  Más mian leat triail saor in aisce (30 lá) a bheith agat ar an bhfóntas seo, cliceáil le do thoil chun é a íoslódáil, agus ansin téigh chun an oibríocht a chur i bhfeidhm de réir na gcéimeanna thuas.


Earraí gaolmhara:

Uath-chomhiomlán agus tú ag clóscríobh liosta anuas Excel
Má tá liosta anuas bailíochtaithe sonraí agat le luachanna móra, ní mór duit scrollú síos ar an liosta chun an ceann ceart a fháil, nó an focal iomlán a chlóscríobh go díreach sa bhosca liosta. Má tá modh ann chun ligean do uathoibríoch a chomhlánú agus an chéad litir á chlóscríobh ar an liosta anuas, beidh gach rud níos éasca. Soláthraíonn an teagaisc seo an modh chun an fhadhb a réiteach.

Cruthaigh liosta anuas ó leabhar oibre eile in Excel
Tá sé furasta go leor liosta anuas bailíochtaithe sonraí a chruthú i measc bileoga oibre i leabhar oibre. Ach má aimsíonn na sonraí liosta atá uait le haghaidh bailíochtú na sonraí i leabhar oibre eile, cad a dhéanfá? Sa rang teagaisc seo, foghlaimeoidh tú conas liosta titim anuas a chruthú ó leabhar oibre eile in Excel go mion.

Cruthaigh liosta anuas inchuardaithe in Excel
Maidir le liosta anuas le go leor luachanna, ní obair éasca é ceann ceart a aimsiú. Roimhe seo thugamar isteach modh chun an liosta anuas a chomhlánú go huathoibríoch nuair a chuireann tú an chéad litir isteach sa bhosca anuas. Chomh maith leis an bhfeidhm uathchomhiomlán, is féidir leat an liosta anuas a chuardach chun an éifeachtúlacht oibre a fheabhsú chun luachanna cearta a fháil ar an liosta anuas. Chun an liosta anuas a chuardach inchuardaithe, bain triail as an modh sa rang teagaisc seo.

Déan cealla eile a uathoibriú nuair a bhíonn luachanna á roghnú agat ar liosta anuas Excel
Ligean le rá gur chruthaigh tú liosta anuas bunaithe ar na luachanna i raon cille B8: B14. Nuair a roghnaíonn tú luach ar bith ar an liosta anuas, ba mhaith leat go ndéanfaí na luachanna comhfhreagracha i raon cille C8: C14 a dhaonra go huathoibríoch i gcill roghnaithe. Chun an fhadhb a réiteach, is fearr leat na modhanna sa rang teagaisc seo.

Tuilleadh teagaisc don liosta anuas ...


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.
    Margot · 25 days ago
    Hello, thank you for this code, it helped me a lot ! 
    However, i was wondering, is it possible to create a pivot table from this kind of list ? 
    Thanks
  • To post as a guest, your comment is unpublished.
    James · 1 years ago
    How can i get the code to allow the same selection more than once in the drop down?
    Thanks for any help
    • To post as a guest, your comment is unpublished.
      crystal · 11 months ago
      Hi James,
      Kutools can help you solve the problem with ease. You can download a free trial to have a try.
  • To post as a guest, your comment is unpublished.
    Claudia · 1 years ago
    The code is working, so it adds all the choices that I have from my drop down list. However, if I have already chosen three of them, how can I remove one because I have made a mistake?
    For example, I have chosen (one, two and three) and I want to remove "two" by clicking again "two" from the drop down list. It allows no repetition and remove this one.
    • To post as a guest, your comment is unpublished.
      crystal · 1 years ago
      Hi Claudia,
      The code can't be modified to solve this problem.
      You can try the Kutools feature. It meets all your needs.
  • To post as a guest, your comment is unpublished.
    raguirre76@gmail.com · 1 years ago
    I know this may be a total random, but I use a variation of the VBA with no issue. Except on one page, if you select the first three options, it will not let you select the fourth. It will let you select the 5th, 6th, and so on, just not the 4th option. Thoughts?
    • To post as a guest, your comment is unpublished.
      crystal · 1 years ago
      Hi Robert,
      I have tested the code but haven't found the problem as you mentioned. Can you tell me which Excel version are you using? Thank you for your comment.
  • To post as a guest, your comment is unpublished.
    Okot · 1 years ago
    I cannot proceed with creation of the multiple selection of the drop down list. I have listen to tutorial and read material but still unable to create. Kindly can someone help me out?
  • To post as a guest, your comment is unpublished.
    Eni · 1 years ago
    Hi, ich bin totaler VBA Laie. Ich versuche den Code so zu modifizieren, dass
    a) die Mehrfachauswahl nicht in allen, sondern nur ein zwei Spalten aktiv ist
    b) ich Items auch wieder rausnehmen kann, zB in dem ich in der Listenauswahl das Item noch einmal anklicke (Beispiel: ich habe über die Mehrfachauswahl ausgewählt: A, D, X, Y... nun fällt mir auf, dass D nicht dazu gehört. Beim aktuellen Code müsste ich Eingaben entfernen und neu auswählen).
    Danke im Voraus!
  • To post as a guest, your comment is unpublished.
    wendy · 1 years ago
    I'm using the code below to allow multi-select on multiple worksheets but when I go to another worksheet in the workbook the multi-select goes away. When I save the file and come back in it will work for one tab with the code but again when I click on another tab with the code it no longer works. Any idea how to fix it so if i click on a worksheet with the VBA code it will always allow multi-select?
  • To post as a guest, your comment is unpublished.
    Randy · 3 years ago
    I'm trying to create 4 columns with drop down lists where I can select multiple values. How do I modify the "drop down list with multiple selections" VBA code so that when I click on a value that has already been entered it removes it from the cell? Thank you in advance.
    • To post as a guest, your comment is unpublished.
      crystal · 3 years ago
      Dear Randy,
      What do you mean "when I click on a value that has already been entered it removes it from the cell?"
      • To post as a guest, your comment is unpublished.
        Dez · 3 years ago
        I have the same question. My drop down list does not remember values selected. If someone clicks on a cell that has already been populated (not by them, but someone else) the selected values are cleared and the cell is blank again.
  • To post as a guest, your comment is unpublished.
    Johnna · 3 years ago
    I created a drop down list where multiple text selections could be chosen such as "nutrition" ,"weight", and "work" for each caller's reason to phone in. I have a summary page where I want to see how many of each reason were indicated in a particular month. What formula would I use to tell Excel to pull out and tally each of these separately in a given month? Currently, the way I have it set up, it only tallies correctly if I have one reason in the cell for each caller.
    • To post as a guest, your comment is unpublished.
      crystal · 3 years ago
      Good Day,
      Sorry can't help you solve this problem. Please let me know if you find the answer.
  • To post as a guest, your comment is unpublished.
    Nancy · 3 years ago
    I managed to use this code and successfully create multiple selection drop down boxes. It worked when I closed and re-opened on different days. However, now not all of the cells I originally selected are allowing multiple selection. Only ones done previously, despite using the code for the whole spreadsheet. Can you help?
    • To post as a guest, your comment is unpublished.
      yesenia · 3 years ago
      the cells are most likely locked, right click on all of them, go to format cells, protection, then uncheck the locked cell option
    • To post as a guest, your comment is unpublished.
      lthompson@alz.org · 3 years ago
      I'm having the same problem.
  • To post as a guest, your comment is unpublished.
    Desiree · 4 years ago
    Hi all,

    I could do my drop down list perfectly, but my question is: when I select all the items nedded it goes one after another in an horizontal way through the cell, for example: yellow, green, black, red. But how can I make it look in a vertical way?, more like for example: Orange
    blanck
    yellow
    Red
    Because in horizontal the cell becomes pretty long when selecting lots of items.

    Could you please tell me if there's any way to do this?.

    Thank you,

    Desiree
  • To post as a guest, your comment is unpublished.
    Chloe · 4 years ago
    Hi all,

    I have this code on an excel sheet and its cleaning the contents from the drop down list when the cell is selected - I know what part of the code is doing it (the part that says 'fillRng.ClearContents') and I have tried to use some of the above to fix it unsuccessfully... I am new to VBA programming etc. Can anyone offer any help on how to change it so that it when the cell is selected it doesn't clear and entries wont be duplicated please??

    Option Explicit
    Dim fillRng As Range
    Private Sub Worksheet_SelectionChange(ByVal Target As Range)

    Dim Qualifiers As MSForms.ListBox
    Dim LBobj As OLEObject
    Dim i As Long

    Set LBobj = Me.OLEObjects("ListBox1")
    Set Qualifiers = LBobj.Object

    If Target.Row > 3 And Target.Column = 3 Then
    Set fillRng = Target
    With LBobj
    .Left = fillRng.Left
    .Top = fillRng.Top
    .Width = fillRng.Width
    .Height = 155
    .Visible = True
    End With
    Else
    LBobj.Visible = False
    If Not fillRng Is Nothing Then
    fillRng.ClearContents
    With Qualifiers
    If .ListCount 0 Then
    For i = 0 To .ListCount - 1
    If fillRng.Value = "" Then
    If .Selected(i) Then fillRng.Value = .List(i)
    Else
    If .Selected(i) Then fillRng.Value = _
    fillRng.Value & ", " & .List(i)
    End If
    Next
    End If
    For i = 0 To .ListCount - 1
    .Selected(i) = False
    Next
    End With
    Set fillRng = Nothing
    End If
    End If

    End Sub
  • To post as a guest, your comment is unpublished.
    Ramon · 5 years ago
    Hi there,

    Code works fine. However, I can't seem to deselect an item. When I want to remove an item from the selection, it's just not removed. Does anybody else experience this problem too?
    • To post as a guest, your comment is unpublished.
      StPaulSue · 3 years ago
      delete the content in the cell, then reselect
    • To post as a guest, your comment is unpublished.
      THG · 4 years ago
      Was there a response to this issue. It is the same issue I am having. There doesn't seem to be a way to remove an item that has been selected.
  • To post as a guest, your comment is unpublished.
    Charity · 5 years ago
    This works well, but I am unable to remove an item once selected. Any suggestions in case I click on something accidently and need to remove it without (hopefully) clearing the whole cell and starting over?

    Also, for those seeking to define a column or columns, Contextures has a great addition to the code provided here that allows you to do that.
    http://www.contextures.com/excel-data-validation-multiple.html#column
    • To post as a guest, your comment is unpublished.
      Nirmala · 4 years ago
      [quote name="Charity"]This works well, but I am unable to remove an item once selected. Any suggestions in case I click on something accidently and need to remove it without (hopefully) clearing the whole cell and starting over?

      Also, for those seeking to define a column or columns, Contextures has a great addition to the code provided here that allows you to do that.
      http://www.contextures.com/excel-data-validation-multiple.html#column[/quote]

      Code works fine. However, I can't seem to deselect an item. When I want to remove an item from the selection, it's just not removed. Does anybody else experience this problem too?[/quote]

      Hi all,

      Any solutions found for this problem..please share..
  • To post as a guest, your comment is unpublished.
    stef · 5 years ago
    Hi I am currently using this formula and all columns with data validation have the multiple selection option now, however I want to restrict the multiple selection only to one column. Can someone edit this formula for me so the multiple selection can be applied only to Column4? Thanks :)

    Private Sub Worksheet_Change(ByVal Target As Range)
    'Updated: 2016/4/12
    Dim xRng As Range
    Dim xValue1 As String
    Dim xValue2 As String
    If Target.Count > 1 Then Exit Sub
    On Error Resume Next
    Set xRng = Cells.SpecialCells(xlCellTypeAllValidation)
    If xRng Is Nothing Then Exit Sub
    Application.EnableEvents = False
    If Not Application.Intersect(Target, xRng) Is Nothing Then
    xValue2 = Target.Value
    Application.Undo
    xValue1 = Target.Value
    Target.Value = xValue2
    If xValue1 "" Then
    If xValue2 "" Then
    If xValue1 = xValue2 Or _
    InStr(1, xValue1, ", " & xValue2) Or _
    InStr(1, xValue1, xValue2 & ",") Then
    Target.Value = xValue1
    Else
    Target.Value = xValue1 & ", " & xValue2
    End If
    End If
    End If
    End If
    Application.EnableEvents = True
    End Sub

    Any assistance will be appreciated!
  • To post as a guest, your comment is unpublished.
    Mervyn · 5 years ago
    @Cynthia,

    If still required, you should be able to do something like this to only ensure the code runs on specific columns, in my case, column 34 and 35:

    If (Target.Column 34 And Target.Column 35) Then Exit Sub

    'Put this code at the beginning after your dim statements
    • To post as a guest, your comment is unpublished.
      Dhina · 3 years ago
      If Target.Column <> 34 Then Exit Sub

      'Put this code at the beginning after your dim statements
    • To post as a guest, your comment is unpublished.
      CynthiaB · 4 years ago
      [quote name="Mervyn"]@Cynthia,

      If still required, you should be able to do something like this to only ensure the code runs on specific columns, in my case, column 34 and 35:

      If (Target.Column 34 And Target.Column 35) Then Exit Sub

      'Put this code at the beginning after your dim statements[/quote]


      Hi @Mervyn,

      Lost track of the thread completely, but thank you so much for your responses.

      I've tried applying the
      If (Target.Column 34 And Target.Column 35) Then Exit Sub
      (my version reads If (Target.Column4 And Target.Column5) Then Exit Sub
      as you supplied, but am getting a "Run-time error '438': Object doesn't support this property or method"" error on this new line.

      Here are the first few lines of my code:

      Private Sub Worksheet_Change(ByVal Target As Range)
      Dim xRng As Range
      Dim xValue1 As String
      Dim xValue2 As String
      If (Target.Column4 And Target.Column5) Then Exit Sub
      If Target.Count > 1 Then Exit Sub

      On Error Resume Next


      My worksheet only has 6 columns: Question | Answer | Category | Sub-Category | Tags | Photo link
      I only need multiple value drop downs in Sub-Category and Tags (columns 4 & 5).

      I'll keep looking for info as you suggested on 12/23, and will look at the link Charity provided.
  • To post as a guest, your comment is unpublished.
    Mervyn · 5 years ago
    Hi Cynthia,

    If the original author doesn't reply, I'll get you an answer but I'll only be in front of a computer on 29 Dec again. I'm also no VBA programmer. What you can do in the mean time is Google search how to identify the column number and only let the code run if data is edited in that specific column(s). I've done it but the code is on my work PC and can't recall it at the moment,maybe try putting a debug.print on target.column or something to that effect to see if it gives you the column number being edited.

    Sorry Jennifer, not sure about the issue you're having :(
  • To post as a guest, your comment is unpublished.
    Jennifer L Price · 5 years ago
    I was able to get the code to work, but then when I saved the document (with macros-enabled), closed it and returned, the code didn't work anymore (though it was still in there). I can't figure out what I've done wrong. Any ideas?
  • To post as a guest, your comment is unpublished.
    CynthiaB · 5 years ago
    Hi. Thank you for the code and the addition to limit duplicates.


    One more request - what addition/change would have to be made in order to allow multiple selection in only one or two specific columns? This code is re-adding lines of text to what should be 'plain' cells if I go to correct a typo, or make a change or addition to the text in the cell, as opposed to just behaving 'normally' and accepting the change (without re-adding the entire text again).

    For instance, column A is a 'plain' column. I write a sentence "What are the three itmes you want most?" Column B is a 'list' column where I only want to be able to pick one single value (in this case, let's say a child's name). Column C is another 'list' column where the user must be able to select multiple items (which this code allows me to do perfectly).

    As I go along, I realize that I've made a typo in column A and want to correct it. As this code stands, if I go in (double click, F2) and make the correction to the word "items", I end up with this result in my cell:"What are the three itmes you want most? What are the three items you want most?"

    thank you in advance for any help (from a user that REALLY likes VBA, but is still at the very earliest stages of learning!)
  • To post as a guest, your comment is unpublished.
    Mervyn · 5 years ago
    Just realised I didn't exit the loop in the new function if the condition has been set so we don't have to check other entries.
  • To post as a guest, your comment is unpublished.
    Mervyn · 5 years ago
    You can change the code in the following lines to prevent the duplicates:
    If xValue2 "" Then
    Target.Value = xValue1 & ", " & xValue2
    End If

    To:
    If xValue2 "" Then
    If CheckIfAlreadyAdded(xValue1, xValue2) = False Then
    Target.Value = xValue1 & ", " & xValue2
    Else
    Target.Value = xValue1
    End If
    End If

    And then add the following function:
    Private Function CheckIfAlreadyAdded(ByVal sText As String, sNewValue As String) As Boolean

    CheckIfAlreadyAdded = False

    Dim WrdArray() As String
    WrdArray() = Split(sText, ",")

    For i = LBound(WrdArray) To UBound(WrdArray)
    If Trim(WrdArray(i)) = Trim(sNewValue) Then CheckIfAlreadyAdded = True
    Next i

    End Function

    --
    There's probably better ways of coding it but it works for now.
  • To post as a guest, your comment is unpublished.
    MichaelB · 5 years ago
    It is great that this allows multiple selections but like @Yezdi commented, I am finding it will add one or several duplicates even if I don't choose them.

    So, at present, this is an 80% solution... one tweak away from perfect. I am not a VB coder or I'd offer the solution.
  • To post as a guest, your comment is unpublished.
    Yezdi Eks · 5 years ago
    Hi,

    Thanks for the solution and the code.

    But the next step is how to make sure that the user
    does not select "duplicate" values from the dropdown list.

    E.g. If there are 4 items in the list -
    orange, apple, banana, peach

    and if the user has already selected "orange", then excel
    should not allow the user to select "orange" OR that option
    should be removed from the remainder of the list.

    Can you please publish the code to accomplish this feature.

    Thanks.

    Yezdi
    • To post as a guest, your comment is unpublished.
      sunshine · 5 years ago
      Hi Yezdi,
      Thank you for your comment. The code was updated and no duplicate values allow in the drop-down list now.

      Thanks.

      Sunshine