Note: The other languages of the website are Google-translated. Back to English
登入  \/ 
x
or
x
註冊  \/ 
x

or

警告

JUser :: _load:無法載入用戶ID為:8858

如何在Excel中使用多個複選框創建下拉列表?

許多Excel用戶傾向於創建帶有多個複選框的下拉列表,以便每次都從列表中選擇多個項目。 實際上,您無法使用數據驗證功能創建帶有多個複選框的列表。 在本教程中,我們將向您展示兩種在Excel中創建帶有多個複選框的下拉列表的方法。

使用列錶框創建帶有多個複選框的下拉列表
答:使用源數據創建一個列錶框
B:命名您將找到所選項目的單元格
C:插入形狀以幫助輸出所選項目
使用功能強大的複選框輕鬆創建帶有復選框的下拉列表
下拉列表的更多教程...


使用列錶框創建帶有多個複選框的下拉列表

如下面的屏幕截圖所示,在當前工作表中,範圍A2:A11中的所有名稱將成為列錶框的源數據。 單擊單元格C4中的按鈕可以輸出選定的項目,列錶框中的所有選定項目將顯示在單元格E4中。 為此,請執行以下操作。

A.創建一個帶有源數據的列錶框

1。 點擊 開發人員 > 插入 > 列錶框(Active X控件)。 看截圖:

2.在當前工作表中繪製一個列錶框,右鍵單擊它,然後選擇 氟化鈉性能 從右鍵單擊菜單中。

3。 在裡面 氟化鈉性能 對話框,您需要配置如下。

  • 3.1在 列表填充範圍 框,輸入您將在列表中顯示的來源範圍(此處輸入範圍 A2:A11);
  • 3.2在 列表樣式 框中選擇 1-fmList StyleOption;
  • 3.3在 多選 框中選擇 1 – fmMultiSelectMulti;
  • 3.4關閉 氟化鈉性能 對話框。 看截圖:

B:命名您將找到所選項目的單元格

如果需要將所有選擇的項目輸出到指定的單元格(例如E4)中,請執行以下操作。

1.選擇單元格E4,輸入 列錶框輸出名稱框 並按下 Enter 鍵。

C.插入形狀以幫助輸出所選項目

1。 點擊 插入 > 形狀 > 長方形。 見截圖:

2.在工作表中繪製一個矩形(此處在單元格C4中繪製該矩形)。 然後右鍵單擊矩形並選擇 分配宏 從右鍵單擊菜單中。

3。 在裡面 分配宏 對話框中,單擊 新穎 按鈕。

4.在開幕 Microsoft Visual Basic for Applications 窗口,請替換原始代碼 模塊 帶有以下VBA代碼的窗口。

VBA代碼:創建帶有多個複選框的列表

Sub Rectangle1_Click()
'Updated by Extendoffice 20200730
Dim xSelShp As Shape, xSelLst As Variant, I, J As Integer
Dim xV As String
Set xSelShp = ActiveSheet.Shapes(Application.Caller)
Set xLstBox = ActiveSheet.ListBox1
If xLstBox.Visible = False Then
    xLstBox.Visible = True
    xSelShp.TextFrame2.TextRange.Characters.Text = "Pickup Options"
    xStr = ""
    xStr = Range("ListBoxOutput").Value
    
    If xStr <> "" Then
         xArr = Split(xStr, ";")
    For I = xLstBox.ListCount - 1 To 0 Step -1
        xV = xLstBox.List(I)
        For J = 0 To UBound(xArr)
            If xArr(J) = xV Then
              xLstBox.Selected(I) = True
              Exit For
            End If
        Next
    Next I
    End If
Else
    xLstBox.Visible = False
    xSelShp.TextFrame2.TextRange.Characters.Text = "Select Options"
    For I = xLstBox.ListCount - 1 To 0 Step -1
        If xLstBox.Selected(I) = True Then
        xSelLst = xLstBox.List(I) & ";" & xSelLst
        End If
    Next I
    If xSelLst <> "" Then
        Range("ListBoxOutput") = Mid(xSelLst, 1, Len(xSelLst) - 1)
    Else
        Range("ListBoxOutput") = ""
    End If
End If
End Sub

備註: 在代碼中 矩形1 是形狀名稱; ListBox1 是列錶框的名稱; 選擇選項接送選項 是形狀顯示的文字; 和 列錶框輸出 是輸出單元格的範圍名稱。 您可以根據需要進行更改。

5。 按 其他 + Q 同時關閉按鍵 Microsoft Visual Basic for Applications 窗口。

6.單擊矩形按鈕將折疊或展開列錶框。 當列錶框展開時,檢查列錶框中的項目,然後再次單擊矩形以將所有選定的項目輸出到單元格E4中。 參見下面的演示:

7.然後將工作簿另存為 Excel MacroEnable工作簿 用於將來重用代碼。


使用功能強大的工具創建帶有復選框的下拉列表

上述方法過於復雜,難以處理。 在這裡強烈推薦 帶有復選框的下拉列表 的效用 Kutools用於 Excel 幫助您輕鬆創建帶有指定範圍,當前工作表,當前工作簿或所有打開的工作簿的複選框的下拉列表(根據您的需要)。 請參見下面的演示:
立即下載並試用! ( 30 天免費試用)

除了上述演示之外,我們還提供了逐步指南,以演示如何應用此功能來完成此任務。 請執行以下操作。

1.打開已設置數據驗證的工作表下拉列表,單擊 庫工具 > 下拉列表 > 帶有復選框的下拉列表 > 設置。 見截圖:

2。 在裡面 下拉列表和復選框設置 對話框,請進行以下配置。

  • 2.1)在 適用於 部分,指定您將在其中創建下拉列表中項目複選框的應用範圍。 您可以指定一個 一定範圍, 當前工作表, 當前工作簿 or 所有打開的工作簿 根據您的需求。
  • 2.2)在 模式 部分中,選擇要輸出所選項目的樣式;
  • 這裡需要 修改 選項為例,如果選擇此選項,則單元格值將根據所選項目進行更改。
  • 2.3)在 分離器 框,輸入一個定界符,您將使用該定界符將多個項目分開;
  • 2.4)在 文本方向 部分,根據需要選擇文本方向;
  • 2.5)點擊 OK 按鈕。

3.最後一步,單擊 庫工具 > 下拉列表 > 帶有復選框的下拉列表 > 啟用複選框的下拉列表 激活此功能。

從現在開始,當您單擊指定範圍內帶有下拉列表的單元格時,將彈出一個列錶框,請選中復選框以選擇項目以輸出到單元格中,如下圖所示(以“修改”模式為例) )。

有關此功能的更多詳細信息, 請訪問這裡.

  如果您想免費試用此實用程序(30 天), 請點擊下載,然後按照上述步驟進行操作。


相關文章:

在Excel下拉列表中鍵入時自動完成
如果您有一個包含大值的數據驗證下拉列表,則需要在列表中向下滾動以查找合適的列表,或直接在列錶框中鍵入整個單詞。 如果在下拉列表中鍵入第一個字母時有允許自動完成的方法,一切將變得更加容易。 本教程提供了解決問題的方法。

在Excel中從另一個工作簿創建下拉列表
在工作簿中的工作表之間創建數據驗證下拉列表非常容易。 但是,如果數據驗證所需的列表數據位於另一個工作簿中,您將怎麼辦? 在本教程中,您將詳細了解如何從Excel中的另一個工作簿創建拖放列表。

在Excel中創建可搜索的下拉列表
對於具有眾多價值的下拉列表,找到合適的價值並非易事。 以前,我們已經介紹了一種在下拉框中輸入第一個字母時自動完成下拉列表的方法。 除了自動完成功能之外,您還可以使下拉列表可搜索,以提高在下拉列表中查找適當值時的工作效率。 為了使下拉列表可搜索,請嘗試本教程中的方法。

在Excel下拉列表中選擇值時自動填充其他單元格
假設您已經根據單元格區域B8:B14中的值創建了一個下拉列表。 在下拉列表中選擇任何值時,都希望在選定單元格中自動填充單元格範圍C8:C14中的相應值。 為了解決該問題,本教程中的方法將對您有所幫助。

下拉列表的更多教程...


最佳辦公效率工具

Kutools for Excel 解決了您的大部分問題,並將您的生產力提高了 80%

  • 重用: 快速插入 複雜的公式,圖表 以及您以前使用過的任何東西; 加密單元 帶密碼 創建郵件列表 並發送電子郵件...
  • 超級公式欄 (輕鬆編輯多行文本和公式); 閱讀版式 (輕鬆讀取和編輯大量單元格); 粘貼到過濾範圍...
  • 合併單元格/行/列 不會丟失數據; 拆分單元格內容; 合併重複的行/列...防止細胞重複; 比較範圍...
  • 選擇重複或唯一 行; 選擇空白行 (所有單元格都是空的); 超級查找和模糊查找 在許多工作簿中; 隨機選擇...
  • 確切的副本 多個單元格,無需更改公式參考; 自動創建參考 到多張紙; 插入項目符號,複選框等...
  • 提取文字,添加文本,按位置刪除, 刪除空間; 創建和打印分頁小計; 在單元格內容和註釋之間轉換...
  • 超級濾鏡 (將過濾方案保存並應用於其他工作表); 高級排序 按月/週/日,頻率及更多; 特殊過濾器 用粗體,斜體...
  • 結合工作簿和工作表; 根據關鍵列合併表; 將數據分割成多個工作表; 批量轉換xls,xlsx和PDF...
  • 300 多項強大功能。 支持Office / Excel 2007-2019和365。支持所有語言。 在您的企業或組織中輕鬆部署。 完整功能30天免費試用。 60天退款保證。
kte選項卡201905

Office選項卡為Office帶來了選項卡式界面,使您的工作更加輕鬆

  • 在Word,Excel,PowerPoint中啟用選項卡式編輯和閱讀,發布者,Access,Visio和Project。
  • 在同一窗口的新選項卡中而不是在新窗口中打開並創建多個文檔。
  • 將您的工作效率提高 50%,每天為您減少數百次鼠標點擊!
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.
    Morgane K · 3 months ago
    Bonjour,
    Je suis plus que novice sur excel étant sur mac je ne peux utiliser l'outil Kutools j'ai donc tenté de créer une liste déroulante où l'on peut cocher plusieurs items mais je bloque dès le début dans l'onglet développeur puisque je n'ai pas du tout l'outil "insert".
    Merci pour votre aide
  • To post as a guest, your comment is unpublished.
    Gowtham · 8 months ago
    Hi I am newbie to VBA. I tried to execute the code but i get the following error "Run-time error '-2147024809 (80070057)': The Item with the specified name wasn't found". Can you help me with this
    • To post as a guest, your comment is unpublished.
      crystal · 8 months ago
      Hi Gowtham,
      It seem that this error occurs when you running the code directly in the Code editor (the Microsoft Visual Basic for Applications window).
      After adding the code, please press the Alt + Q keys to close the Microsoft Visual Basic for Applications window.
      Go back to the worksheet and execute the code by clicking the rectangle button (see the .gif picture in step 6).
      • To post as a guest, your comment is unpublished.
        minapnh · 4 days ago
        Hi Crystal, even after your tip am getting same error as Gowtham. My error is right after protect my sheet.  Would you please help me with this issue?
      • To post as a guest, your comment is unpublished.
        Mina · 4 days ago
        Hi Crystal, Even After your tip I am getting same error as Gowtham.

  • To post as a guest, your comment is unpublished.
    fbjr · 9 months ago
    Hello,
    I added this code to an existing macro template and it is loading the selections correctly, but it is NOT clearing out the x on the selected items..
    This will be used on/in a template worksheet that has submit button/macro to load the worksheet answers into a hidden worksheet with a data table.
    And am happy to say the field data loaded to the cell, transferred into my variable, and loaded to the data table as expected.

    This code was a HUGE blessing!

    I use excel 2016

    How do I fix this. I am using this version from below.

    Sub Rectangle1_Click()
    'Updated by Extendoffice 20200730
    Dim xSelShp As Shape, xSelLst As Variant, I, J As Integer
    Dim xV As String
    Set xSelShp = ActiveSheet.Shapes(Application.Caller)
    Set xLstBox = ActiveSheet.ListBox1
    If xLstBox.Visible = False Then
    xLstBox.Visible = True
    xSelShp.TextFrame2.TextRange.Characters.Text = "Pickup Options"
    xStr = ""
    xStr = Range("ListBoxOutput").Value

    If xStr <> "" Then
    xArr = Split(xStr, ";")
    For I = xLstBox.ListCount - 1 To 0 Step -1
    xV = xLstBox.List(I)
    For J = 0 To UBound(xArr)
    If xArr(J) = xV Then
    xLstBox.Selected(I) = True
    Exit For
    End If
    Next
    Next I
    End If
    Else
    xLstBox.Visible = False
    xSelShp.TextFrame2.TextRange.Characters.Text = "Select Options"
    For I = xLstBox.ListCount - 1 To 0 Step -1
    If xLstBox.Selected(I) = True Then
    xSelLst = xLstBox.List(I) & ";" & xSelLst
    End If
    Next I
    If xSelLst <> "" Then
    Range("ListBoxOutput") = Mid(xSelLst, 1, Len(xSelLst) - 1)
    Else
    Range("ListBoxOutput") = ""
    End If
    End If
    End Sub
  • To post as a guest, your comment is unpublished.
    ben · 11 months ago
    Hello,

    I'm having a similar problem to Tom from 2 months ago. When I try to share my file with a colleague, the multi-select droplist list isn't working. However, I used the Kutools add-on to create this as opposed to creating it myself. I've also saved it as macro-enabled.
    • To post as a guest, your comment is unpublished.
      crystal · 11 months ago
      Hi ben,
      The multi-select drop down list feature of Kutools only works in the Excel that installed our Kutools. We are working on this issue, sorry for the inconvenience.
  • To post as a guest, your comment is unpublished.
    Tom · 1 years ago
    Hello I looking the resolve for problem with saving choosing on drop down list
    when i choose something on list and send file to my colleague, then when he open file and want to check my list then list has cleared and cell "ListBoxOutput" was cleared too.
    help please :)
    • To post as a guest, your comment is unpublished.
      crystal · 1 years ago
      Hi Tom,
      Please save the workbook as an "Excel MacroEnable Workbook" and then send this .xlsm file to your colleague.
      • To post as a guest, your comment is unpublished.
        Tom · 1 years ago
        hello i save this file in this format from beginning ;), but without effect. still when i fill file and send to someone then when he opened file and click to "shape" then macro started from begin and cleared list

        • To post as a guest, your comment is unpublished.
          crystal · 1 years ago
          Hi Tom,
          I am sorry for the mistake. The code has been updated again. Please have a try.

          Sub Rectangle1_Click()
          'Updated by Extendoffice 20200730
          Dim xSelShp As Shape, xSelLst As Variant, I, J As Integer
          Dim xV As String
          Set xSelShp = ActiveSheet.Shapes(Application.Caller)
          Set xLstBox = ActiveSheet.ListBox1
          If xLstBox.Visible = False Then
          xLstBox.Visible = True
          xSelShp.TextFrame2.TextRange.Characters.Text = "Pickup Options"
          xStr = ""
          xStr = Range("ListBoxOutput").Value

          If xStr <> "" Then
          xArr = Split(xStr, ";")
          For I = xLstBox.ListCount - 1 To 0 Step -1
          xV = xLstBox.List(I)
          For J = 0 To UBound(xArr)
          If xArr(J) = xV Then
          xLstBox.Selected(I) = True
          Exit For
          End If
          Next
          Next I
          End If
          Else
          xLstBox.Visible = False
          xSelShp.TextFrame2.TextRange.Characters.Text = "Select Options"
          For I = xLstBox.ListCount - 1 To 0 Step -1
          If xLstBox.Selected(I) = True Then
          xSelLst = xLstBox.List(I) & ";" & xSelLst
          End If
          Next I
          If xSelLst <> "" Then
          Range("ListBoxOutput") = Mid(xSelLst, 1, Len(xSelLst) - 1)
          Else
          Range("ListBoxOutput") = ""
          End If
          End If
          End Sub
          • To post as a guest, your comment is unpublished.
            Tom · 1 years ago
            Now it's working perfectly.
            Many thanks for your help
  • To post as a guest, your comment is unpublished.
    Lesley Cantu · 1 years ago
    Hi! What would I need to do if I want to place multiple drop down lists on one sheet?
    • To post as a guest, your comment is unpublished.
      crystal · 1 years ago
      Good day,
      You can browse the below page to find the solution.
      https://www.extendoffice.com/documents/excel/915-excel-insert-drop-down-list.html

  • To post as a guest, your comment is unpublished.
    Elston Hynd · 1 years ago
    Hi, I have used your code below to create a multiple drop down box in excel that is also able to work when the worksheet is in protected mode. However, it only works in the one ListOutputBox (cell O38). I want it to work in a range of cells (O38:O239). What do I need to change?


    Sub Rectangle3_Click()
    'Updated by Extendoffice 20191114
    Dim xSelShp As Shape, xSelLst As Variant, i As Integer
    Set xSelShp = ActiveSheet.Shapes(Application.Caller)
    Set xLstBox = ActiveSheet.ListBox1
    If xLstBox.Visible = False Then
    xLstBox.Visible = True
    xSelShp.TextFrame2.TextRange.Characters.Text = "Pickup Options"
    Else
    xLstBox.Visible = False
    xSelShp.TextFrame2.TextRange.Characters.Text = "Select Options"
    For i = xLstBox.ListCount - 1 To 0 Step -1
    If xLstBox.Selected(i) = True Then
    xSelLst = xLstBox.List(i) & ", " & xSelLst
    End If
    Next i
    If xSelLst <> "" Then
    Range("ListBoxOutput") = Mid(xSelLst, 1, Len(xSelLst) - 1)
    Else
    Range("ListBoxOutput") = ""
    End If
    End If
    End Sub
  • To post as a guest, your comment is unpublished.
    Chez Baker · 2 years ago
    How would you make the output names display to different cells instead of being put together in one? Thank you!
    • To post as a guest, your comment is unpublished.
      crystal · 2 years ago
      Hi Chez Baker,
      With the below VBA code, you can fill the multiselection in different cells on the same row. Please have a try.

      Sub Rectangle2_Click()
      'Updated by Extendoffice 20190924
      Dim xSelShp As Shape, xSelLst As Variant, I As Integer
      Dim xRg As Range
      Set xSelShp = ActiveSheet.Shapes(Application.Caller)
      Set xLstBox = ActiveSheet.ListBox1
      If xLstBox.Visible = False Then
      xLstBox.Visible = True
      xSelShp.TextFrame2.TextRange.Characters.Text = "Pickup Options"
      Else
      xLstBox.Visible = False
      xSelShp.TextFrame2.TextRange.Characters.Text = "Select Options"
      Set xRg = Range("ListBoxOutput")
      For I = 0 To xLstBox.ListCount - 1
      If xLstBox.Selected(I) = True Then
      xSelLst = xLstBox.List(I)
      xRg.Value = Mid(xSelLst, 1, Len(xSelLst))
      Set xRg = xRg.Offset(0, 1)
      End If
      Next I
      End If
      End Sub
  • To post as a guest, your comment is unpublished.
    Gustav Benz · 2 years ago
    Thank you so much for this, now how do I put multiple checkbox menus with different macros (as this one only applies to adding one in the excel file)?
    • To post as a guest, your comment is unpublished.
      crystal · 2 years ago
      Good day,
      Sorry can't help you with that. Thank you for your comment.
  • To post as a guest, your comment is unpublished.
    Jorge Valdes · 2 years ago
    hello Crystal, how Can I use this VBA code in order to fill diferents cells, this article is only to fill the multiselection in the same cell... could you help me please?
    • To post as a guest, your comment is unpublished.
      crystal · 2 years ago
      Hi Jorge Valdes,
      With the below VBA code, you can fill the multiselection in different cells on the same row. Please have a try.

      Sub Rectangle2_Click()
      'Updated by Extendoffice 20190924
      Dim xSelShp As Shape, xSelLst As Variant, I As Integer
      Dim xRg As Range
      Set xSelShp = ActiveSheet.Shapes(Application.Caller)
      Set xLstBox = ActiveSheet.ListBox1
      If xLstBox.Visible = False Then
      xLstBox.Visible = True
      xSelShp.TextFrame2.TextRange.Characters.Text = "Pickup Options"
      Else
      xLstBox.Visible = False
      xSelShp.TextFrame2.TextRange.Characters.Text = "Select Options"
      Set xRg = Range("ListBoxOutput")
      For I = 0 To xLstBox.ListCount - 1
      If xLstBox.Selected(I) = True Then
      xSelLst = xLstBox.List(I)
      xRg.Value = Mid(xSelLst, 1, Len(xSelLst))
      Set xRg = xRg.Offset(0, 1)
      End If
      Next I
      End If
      End Sub
      • To post as a guest, your comment is unpublished.
        Amy · 1 years ago
        too cool! Thank you!
  • To post as a guest, your comment is unpublished.
    Jimmy · 2 years ago
    Como puedo replicar éste ejercicio en las filas inferiores ?
    How can I replicate this exercise in the rows below?
  • To post as a guest, your comment is unpublished.
    alcatel · 2 years ago
    HELP!!! how output in different ranges (vertically)?
    • To post as a guest, your comment is unpublished.
      Jea Perez · 1 years ago
      Sub Rectangle2_Click()
      'Updated by Extendoffice 20190924
      Dim xSelShp As Shape, xSelLst As Variant, I As Integer
      Dim xRg As Range
      Set xSelShp = ActiveSheet.Shapes(Application.Caller)
      Set xLstBox = ActiveSheet.ListBox1
      If xLstBox.Visible = False Then
      xLstBox.Visible = True
      xSelShp.TextFrame2.TextRange.Characters.Text = "Pickup Options"
      Else
      xLstBox.Visible = False
      xSelShp.TextFrame2.TextRange.Characters.Text = "Select Options"
      Set xRg = Range("ListBoxOutput")
      For I = 0 To xLstBox.ListCount - 1
      If xLstBox.Selected(I) = True Then
      xSelLst = xLstBox.List(I)
      xRg.Value = Mid(xSelLst, 1, Len(xSelLst))
      Set xRg = xRg.Offset(1, 0)
      End If
      Next I
      End If
      End Sub
  • To post as a guest, your comment is unpublished.
    alcat · 2 years ago
    Добрый день! Прошу помочь.
    Как сделать так чтобы каждое значение выходило на новой клетке? чтобы по выходило по вертикали?
  • To post as a guest, your comment is unpublished.
    binoy · 2 years ago
    It is working fine, thanks a lot for your help. I have one issue here is that, all the output is coming in the same cell E4, how can we get the output in different cells Eg: output for C4 in E4, C5 in E5 ,C6 in E6 etc.
    • To post as a guest, your comment is unpublished.
      crystal · 2 years ago
      Good Day,
      The problem you mentioned can't be solve yet.
  • To post as a guest, your comment is unpublished.
    LizKats · 3 years ago
    Hello,

    I am wondering if there is a way to direct the pickup options to more than one cell (not just E4), or make the selections a dropdown checklist so that I can select multiple options off a checklist, but do so repeatedly and independent of the other selections I've made. For example, how would I go about using the same list of pickup options to input a different selection of items to E5, E6, E7, etc. from the same pickup list.

    Thank you
    • To post as a guest, your comment is unpublished.
      crystal · 1 years ago
      Hi LizKats,
      Please try the below code. Hope I can help. Thank you.

      Sub Rectangle2_Click()
      'Updated by Extendoffice 20200529
      Dim xSelShp As Shape, xSelLst As Variant, i As Integer
      Set xSelShp = ActiveSheet.Shapes(Application.Caller)
      Set xLstBox = ActiveSheet.ListBox1
      Dim xRg As Range
      Dim xCount, xFNum, xR, xC As Integer
      Dim xStr As String
      If xLstBox.Visible = False Then
      xLstBox.Visible = True
      xSelShp.TextFrame2.TextRange.Characters.Text = "Pickup Options"
      Else
      xLstBox.Visible = False
      xSelShp.TextFrame2.TextRange.Characters.Text = "Select Options"
      Set xRg = Range("ListBoxOutput")
      xCount = xLstBox.ListCount - 1
      xStr = ""
      For i = xLstBox.ListCount - 1 To 0 Step -1
      If xLstBox.Selected(i) = True Then
      xStr = xLstBox.List(i) & ";" & xStr
      End If
      Next i

      If xRg.Value = "" Then
      xRg.Value = xStr
      Else
      Set xRg = xRg.Offset(1, 0)
      Do While xRg.Value <> ""
      Set xRg = xRg.Offset(1, 0)
      Loop
      xRg.Value = xStr
      End If
      End If
      End Sub
  • To post as a guest, your comment is unpublished.
    mark · 3 years ago
    amazing its working but i have one issue after i save the file and open it again the all check from the checkbox list is all gone
    can you help me to this one thank you so much
    • To post as a guest, your comment is unpublished.
      crystal · 3 years ago
      Dear mark,
      We have published an article "How to save or retain selections of ActiveX list boxes in Excel?" which introduces method of saving the selections of list boxes after close and reopen the workbook.
      You can follow this link to get more information: https://www.extendoffice.com/documents/excel/5051-excel-listbox-save-selection.html
    • To post as a guest, your comment is unpublished.
      mark · 3 years ago
      also, it changes the size of the list box and shape always after save and open again the file if someone has a solution for this issue please help me

      thank you so much
  • To post as a guest, your comment is unpublished.
    Angel · 3 years ago
    AMAZING its working but after i close the excel and open it again the check from the checkbox is gone so if i click the button all list will be gone any solution for this
    please someone help me
    Thank you so much in advanced
    • To post as a guest, your comment is unpublished.
      crystal · 3 years ago
      Dear Angel,
      We have published an article "How to save or retain selections of ActiveX list boxes in Excel?" which introduces method of saving the selections of list boxes after close and reopen the workbook.
      You can follow this link to get more information: https://www.extendoffice.com/documents/excel/5051-excel-listbox-save-selection.html
  • To post as a guest, your comment is unpublished.
    milindghadi07@gmail.com · 3 years ago
    i want automatically update names in different columns. is it possible if possible kindly share me the code.
  • To post as a guest, your comment is unpublished.
    · 3 years ago
    "I have created a file using ActiveX list box as you are explained,there i have entered some data and and added some properties too.i have checked some data using the checkbox in the list ,and saved & exit from the file. But while re-opening the file it's not showing any checked data..can anybody give me a suggestion to save those updationes."
    Can anybody help me please.
    • To post as a guest, your comment is unpublished.
      crystal · 3 years ago
      Besides, you need to save the workbook as an Excel Macro-enabled Workbook, and activate the code every time you change the selections of the list box.
    • To post as a guest, your comment is unpublished.
      crystal · 3 years ago
      Good Day,
      Please place the below VBA code into ThisWorkbook code window.
      In the code, Sheet6 is the default name of the worksheet which contains the List Box you want to retain the selections as below screenshot shown. And ListBox1 is the name of the list box. Please change them as you need.

      Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
      Call SaveSelections
      End Sub

      Private Sub Workbook_Open()
      Call RestoreSelections
      End Sub

      Private Sub SaveSelections()

      Dim arr() As Variant, i As Long, j As Long

      With Sheet6.OLEObjects("ListBox1").Object
      If .ListIndex > 0 Then
      For i = 0 To .ListCount - 1
      If .Selected(i) Then
      j = j + 1
      ReDim Preserve arr(1 To j)
      arr(j) = i
      End If
      Next
      Names.Add Name:="Selections", RefersTo:=arr, Visible:=False
      End If
      End With

      End Sub

      Private Sub RestoreSelections()

      Dim arr As Variant, i As Integer

      arr = [Selections]

      With Sheet6.OLEObjects("ListBox1").Object
      For i = 1 To UBound(arr)
      .Selected(arr(i)) = True
      Next
      End With

      End Sub
      • To post as a guest, your comment is unpublished.
        · 3 years ago
        Thank you for the reply sir ,but its not working in the case of my file , can u please send your mail id , so that i can mail you my file to you.
        Thanks in advance
        • To post as a guest, your comment is unpublished.
          crystal · 3 years ago
          Dear manjusha isac,
          Please send your file to zxm@addin99.com. Hope I can help.
  • To post as a guest, your comment is unpublished.
    amit7138@yahoo.com · 3 years ago
    Work perfectly as per the Instructions. But, How can I use this on a Protected sheet. Currently If I use this after protecting the sheet It gives me and error "Run-time error '-2147024809 (80070057)': The Specified Value is out of Range"
    • To post as a guest, your comment is unpublished.
      crystal · 3 years ago
      Dear Amit Sood,
      Before protecting the worksheet, please format the Output cell as unlocked and then apply the below VBA code. Thank you for your comment.

      Sub Rectangle2_Click()
      Dim xSelShp As Shape, xSelLst As Variant, I As Integer
      On Error Resume Next
      Set xSelShp = ActiveSheet.Shapes(Application.Caller)
      Set xLstBox = ActiveSheet.ListBox1
      If xLstBox.Visible = False Then
      xLstBox.Visible = True
      xSelShp.TextFrame2.TextRange.Characters.Text = "Pickup Options"
      Else
      xLstBox.Visible = False
      xSelShp.TextFrame2.TextRange.Characters.Text = "Select Options"
      For I = xLstBox.ListCount - 1 To 0 Step -1
      If xLstBox.Selected(I) = True Then
      xSelLst = xLstBox.List(I) & ";" & xSelLst
      End If
      Next I
      If xSelLst <> "" Then
      Range("ListBoxOutput") = Mid(xSelLst, 1, Len(xSelLst) - 1)
      Else
      Range("ListBoxOutput") = ""
      End If
      End If
      End Sub
  • To post as a guest, your comment is unpublished.
    Amit Sood · 3 years ago
    It works perfectly as per the instructions, However if I protect the sheet it gives and error. Any workaround for this?
  • To post as a guest, your comment is unpublished.
    gohardrgohome · 3 years ago
    I'm a newbie to this but can anyone tell me how to create a mult-selection ListBox that will open, e.g., when I select a name. I want the list box to fit in a single.
    EXAMPLE: I have a list of names with contact info, etc. I want to create a duplicate Listbox for each name in my list. I'd like it to open automatically when I select a name and collapse back into the cell when I go to another row of info. Please advise. Thanks in advance.
    • To post as a guest, your comment is unpublished.
      crystal · 3 years ago
      Dear Randy,
      Sorry can't solve this probem.
  • To post as a guest, your comment is unpublished.
    MartSkot · 3 years ago
    Thank you! It is great and it works!
  • To post as a guest, your comment is unpublished.
    VBR looser · 4 years ago
    Once the output is done and press the button again, the previous selected items in the list box cannot be changed. How to resolve?
  • To post as a guest, your comment is unpublished.
    gimmic · 4 years ago
    could you please explain how can i easily copy this listbox for 100 rows? (seperate listboxes for each of 100 rows)
  • To post as a guest, your comment is unpublished.
    gimmic · 4 years ago
    Hello
    How can copy this listbox for multi cells. Just copy and paste is not working. Could you please explain for example in each cells (E5,E6,E7,E8,...) how can i put this selection box?
  • To post as a guest, your comment is unpublished.
    harshit · 4 years ago
    can you please explain how you have added ListBoxOutput on E4 cell
  • To post as a guest, your comment is unpublished.
    Chris M · 4 years ago
    This is just what i have been looking fo, is there a modification to the code that will put the next selection from the listbox in the next line. for eg
    one
    two
    three
    Instead of :
    one, two, three
  • To post as a guest, your comment is unpublished.
    Chris M · 4 years ago
    This is exactly what I have been looking for, can the code be modified to allow the selected data to display in separate cells down the column? so instead of:
    Monday, Tuesday, Wednesday,
    display as.
    Monday
    Tuesday
    Wednesday
  • To post as a guest, your comment is unpublished.
    Gazali Yakubu · 4 years ago
    This is fantastic. But will be better if the multi selection can be placed at where the cursor is active. Not necessarily what the code specifies.