メインコンテンツへスキップ

Excelのドロップダウンリストに入力するときにオートコンプリートするにはどうすればよいですか?

多くのアイテムを含むデータ検証ドロップダウン リストの場合、リストを上下にスクロールして必要なアイテムを見つけるか、単語全体をリスト ボックスに正しく入力する必要があります。 対応する文字を入力するときにドロップダウン リストをオートコンプリートにする方法はありますか? これにより、セル内にドロップダウン リストがあるワークシートでより効率的に作業することができます。 このチュートリアルでは、それを達成するのに役立つ XNUMX つの方法を提供します。

VBA コードでドロップダウン リストをオートコンプリートする
ドロップダウン リストを 2 秒で簡単にオートコンプリートする

ドロップダウンリストのその他のチュートリアル...


VBA コードでドロップダウン リストをオートコンプリートする

セルに対応する文字を入力した後、ドロップダウンリストをオートコンプリートするには、次のようにしてください。

まず、コンボボックスをワークシートに挿入し、そのプロパティを変更する必要があります。
  1. オートコンプリートにしたいドロップダウン リストのセルを含むワークシートを開きます。
  2. コンボ ボックスを挿入する前に、Excel リボンに [開発] タブを追加する必要があります。 [開発] タブがリボンに表示されている場合は、 ステップ3にシフト. それ以外の場合は、次のようにしてリボンに [開発者] タブを表示します。 File > オプション を開く オプション 窓。 これで Excelのオプション ウィンドウ、クリック リボンをカスタマイズする 左側のペインで、 Developer ボックスをクリックし、 OK ボタン。 スクリーンショットを参照してください:
  3. Developer > インセット > コンボボックス(ActiveXコントロール).
  4. 現在のワークシートにコンボ ボックスを描画します。右クリックして選択します プロパティ 右クリックメニューから。
  5. プロパティ ダイアログボックスで、元のテキストを置き換えてください (氏名) フィールド付き TempCombo。
  6. オフにする デザインモード クリックして Developer > デザインモード。
次に、以下のVBAコードを適用します
  1. 現在のシート タブを右クリックし、 コードを表示 コンテキストメニューから。 スクリーンショットを参照してください:
  2. オープニング アプリケーション向け Microsoft Visual Basic ウィンドウで、以下のVBAコードをコピーしてワークシートのコードウィンドウに貼り付けてください。
    VBAコード:ドロップダウンリストに入力するとオートコンプリート
    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    'Update by Extendoffice: 2020/01/16
        Dim xCombox As OLEObject
        Dim xStr As String
        Dim xWs As Worksheet
        Dim xArr
        
        Set xWs = Application.ActiveSheet
        On Error Resume Next
        Set xCombox = xWs.OLEObjects("TempCombo")
        With xCombox
            .ListFillRange = ""
            .LinkedCell = ""
            .Visible = False
        End With
        If Target.Validation.Type = 3 Then
            Target.Validation.InCellDropdown = False
            Cancel = True
            xStr = Target.Validation.Formula1
            xStr = Right(xStr, Len(xStr) - 1)
            If xStr = "" Then Exit Sub
            With xCombox
                .Visible = True
                .Left = Target.Left
                .Top = Target.Top
                .Width = Target.Width + 5
                .Height = Target.Height + 5
                .ListFillRange = xStr
                If .ListFillRange = "" Then
                    xArr = Split(xStr, ",")
                    Me.TempCombo.List = xArr
                End If
                .LinkedCell = Target.Address
            End With
            xCombox.Activate
            Me.TempCombo.DropDown
        End If
    End Sub
    Private Sub TempCombo_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
        Select Case KeyCode
            Case 9
                Application.ActiveCell.Offset(0, 1).Activate
            Case 13
                Application.ActiveCell.Offset(1, 0).Activate
        End Select
    End Sub
  3. イベント 他の + Q キーを同時に閉じて Microsoft VisualBasicアプリケーション 窓。

これ以降、ドロップダウンリストのセルをクリックすると、ドロップダウンリストに自動的にプロンプ​​トが表示されます。 文字の入力を開始して、選択したセルに対応する項目を自動的に入力することができます。 スクリーンショットを参照してください:

注: このコードは、結合されたセルでは機能しません。

ドロップダウン リストを 2 秒で簡単にオートコンプリートする

ほとんどの Excel ユーザーにとって、上記の VBA メソッドは習得が困難です。 しかし、 検索可能なドロップダウンリスト の特徴 Kutools for Excelで、データ検証ドロップダウン リストのオートコンプリートを簡単に有効にできます。 指定された範囲 わずか2秒で。さらに、この機能は Excel のすべてのバージョンで利用できます。

先端: このツールを適用する前に、インストールしてください Kutools for Excel 最初に。 今すぐ無料ダウンロードへ.

  1. ドロップダウン リストでオートコンプリートを有効にするには、まずドロップダウンで範囲を選択します。次に、次の場所に移動します。 クツール タブを選択 ドロップダウンリスト > ドロップダウン リストを検索可能にし、自動ポップアップを作成する.
  2. ドロップダウン リストを検索可能にする ダイアログ ボックスで、 OK ボタンを押して設定を保存します。
結果

設定が完了したら、指定した範囲内のドロップダウン リストのセルをクリックすると、リスト ボックスが表示されます。文字を入力するとき、1 つの項目が正確に一致する限り、その単語全体がリスト ボックス内で即座に強調表示され、Enter キーを押すだけでドロップダウン リストのセルに入力できます。


関連記事:

Excelで複数のチェックボックスを含むドロップダウンリストを作成するにはどうすればよいですか?
多くのExcelユーザーは、一度にリストから複数のアイテムを選択するために、複数のチェックボックスを備えたドロップダウンリストを作成する傾向があります。 実際には、データ検証を使用して複数のチェックボックスを含むリストを作成することはできません。 このチュートリアルでは、Excelで複数のチェックボックスを備えたドロップダウンリストを作成するXNUMXつの方法を紹介します。 このチュートリアルでは、問題を解決する方法を説明します。

Excelで別のブックからドロップダウンリストを作成する
ブック内のワークシート間でデータ検証ドロップダウンリストを作成するのは非常に簡単です。 しかし、データ検証に必要なリストデータが別のブックにある場合は、どうしますか? このチュートリアルでは、Excelの別のブックからドロップファウンリストを作成する方法について詳しく学習します。

Excelで検索可能なドロップダウンリストを作成する
多数の値を持つドロップダウンリストの場合、適切な値を見つけるのは簡単な作業ではありません。 以前、ドロップダウンボックスに最初の文字を入力したときにドロップダウンリストをオートコンプリートする方法を導入しました。 オートコンプリート機能に加えて、ドロップダウンリストを検索可能にして、ドロップダウンリストで適切な値を見つける作業効率を高めることもできます。 ドロップダウンリストを検索可能にするには、このチュートリアルの方法を試してください。

Excelのドロップダウンリストで値を選択すると、他のセルに自動入力されます
セル範囲B8:B14の値に基づいてドロップダウンリストを作成したとします。 ドロップダウンリストで任意の値を選択する場合、セル範囲C8:C14の対応する値が選択したセルに自動的に入力されるようにします。 問題を解決するために、このチュートリアルの方法はあなたに有利になります。

ドロップダウンリストのその他のチュートリアル...

最高のオフィス生産性向上ツール

🤖 Kutools AI アシスタント: 以下に基づいてデータ分析に革命をもたらします。 インテリジェントな実行   |  コードを生成  |  カスタム数式の作成  |  データを分析してグラフを生成する  |  Kutools関数を呼び出す...
人気の機能: 重複を検索、強調表示、または識別する   |  空白行を削除する   |  データを失わずに列またはセルを結合する   |   数式なしのラウンド ...
スーパールックアップ: 複数の基準の VLookup    複数の値の VLookup  |   複数のシートにわたる VLookup   |   ファジールックアップ ....
詳細ドロップダウン リスト: ドロップダウンリストを素早く作成する   |  依存関係のドロップダウン リスト   |  複数選択のドロップダウンリスト ....
列マネージャー: 特定の数の列を追加する  |  列の移動  |  Toggle 非表示列の表示ステータス  |  範囲と列の比較 ...
注目の機能: グリッドフォーカス   |  デザインビュー   |   ビッグフォーミュラバー    ワークブックとシートマネージャー   |  リソースライブラリ (自動テキスト)   |  日付ピッカー   |  ワークシートを組み合わせる   |  セルの暗号化/復号化    リストごとにメールを送信する   |  スーパーフィルター   |   特殊フィルター (太字/斜体/取り消し線をフィルター...) ...
上位 15 のツールセット12 テキスト ツール (テキストを追加, 文字を削除する、...)   |   50+ チャート 種類 (ガントチャート、...)   |   40+ 実用的 (誕生日に基づいて年齢を計算する、...)   |   19 挿入 ツール (QRコードを挿入, パスから画像を挿入、...)   |   12 変換 ツール (数字から言葉へ, 通貨の換算、...)   |   7 マージ&スプリット ツール (高度な結合行, 分割セル、...)   |   ... もっと

Kutools for Excel で Excel スキルを強化し、これまでにない効率を体験してください。 Kutools for Excelは、生産性を向上させ、時間を節約するための300以上の高度な機能を提供します。  最も必要な機能を入手するにはここをクリックしてください...

説明


Officeタブは、タブ付きのインターフェイスをOfficeにもたらし、作​​業をはるかに簡単にします

  • Word、Excel、PowerPointでタブ付きの編集と読み取りを有効にする、パブリッシャー、アクセス、Visioおよびプロジェクト。
  • 新しいウィンドウではなく、同じウィンドウの新しいタブで複数のドキュメントを開いて作成します。
  • 生産性を 50% 向上させ、毎日何百回もマウス クリックを減らすことができます!
Comments (325)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Hi, many thanks for this material. It helped a lot.
This comment was minimized by the moderator on the site
Hello,

following on from my last comment:

I'm setting up 'standard' rows with the dropdown lists in them. These I'm wanting to copy below into an extensive spreadsheet.
Unfortunately the dropdown's don't copy down when I do that after using the VBA.
Is there a way to do whats described above?

Cheers,
Catherine
This comment was minimized by the moderator on the site
Hi Catherine,
The autocomplete drop-down lists generated by VBA code cannot be copied. You can only copy selected items that are displayed in the drop-down cell. Sorry for the inconvenience.
This comment was minimized by the moderator on the site
Hello,

Have implemented this successfully, so thank you for this page and code.
But now I have an associated problem...:

After doing all of the above points, the code works as described, but I cannot do any undo/redo actions in the entire spreadsheet.
Is there a way to turn this combo box on for when I want to work with the dropdowns and off for when I want to work in other cells? so that the undo/redo actions are possible again?
and note, yes I have turned the design mode off after doing the above steps, but it still doesn't help the problem.

Cheers,
Catherine
This comment was minimized by the moderator on the site
Hi Catherine Foley,
If you want to use the undo operation on cells other than the drop-down cells, the following VBA code can help you. Please give it a try.
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
'Update by Extendoffice: 2022/09/22
    Dim xCombox As OLEObject
    Dim xStr As String
    Dim xWs As Worksheet
    Dim xArr
    
    On Error Resume Next

    Set xWs = Application.ActiveSheet
    
    Set xCombox = xWs.OLEObjects("TempCombo")
    If Target.Validation.Type <> 3 Then
        If xCombox.Visible Then
            xCombox.Visible = False
        End If
        Exit Sub
    End If
    
    With xCombox
        .ListFillRange = ""
        .LinkedCell = ""
'        .Visible = False
    End With

    Target.Validation.InCellDropdown = False
    Cancel = True
    xStr = Target.Validation.Formula1
    xStr = Right(xStr, Len(xStr) - 1)
    If xStr = "" Then Exit Sub
    With xCombox
        .Visible = True
        .Left = Target.Left
        .Top = Target.Top
        .Width = Target.Width + 5
        .Height = Target.Height + 5
        .ListFillRange = xStr
        If .ListFillRange = "" Then
            xArr = Split(xStr, ",")
            Me.TempCombo.List = xArr
        End If
        .LinkedCell = Target.Address
    End With
    xCombox.Activate
    Me.TempCombo.DropDown

End Sub
Private Sub TempCombo_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
    Select Case KeyCode
        Case 9
            Application.ActiveCell.Offset(0, 1).Activate
        Case 13
            Application.ActiveCell.Offset(1, 0).Activate
    End Select
End Sub
This comment was minimized by the moderator on the site
I hope now it will be upload
This comment was minimized by the moderator on the site
This code works really well for a single drop down. However, if I have 5 dropdowns using the same list of values but they need to operate independently of each other how is that accomplished? Despite my best efforts, if I put more than one combo box on the page, any selection is one is mirrored in the other.
This comment was minimized by the moderator on the site
Hi Mbuchmeier,Only need one combo box on the page. The code works on all drop-down lists in current page. You just need to manually click on the drop-down list cell to activate the combo box.
This comment was minimized by the moderator on the site
Hi crystal,
I am working with the combo box (The VBA code from 2021/11/05). It is working great and very useful but there are 2 issues:1. Issue #1: Usually when you work on any cell in Excel, there is indication on the row number which indicate which row you work about. When the combo box is opened this indication is missing2.  Issue #2: When the combo box is opened in the last column of the dynamic table, then it isn't  working as usual: when I select value from the list, the cell remain empty until I move the cursor to another cell
Attached screenshot.
Thank in advance
This comment was minimized by the moderator on the site
Hi Yoni,Thanks for your feedback. For the issues you mentioned:1. Issue #1: Excel does not highlight the row number when selecting an object in the worksheet. Since we use a combo box to replace the data validation drop-down list to handle the autocomplete operation, we can't show the indication in this case;2. Issue #2: I have tried as you described, but the problem cannot be reproduced. The screenshot you attached does not display, you need to save the screenshot and uplode it via the "Upload files" button below.
This comment was minimized by the moderator on the site
Hi Crystal,Thanks a lot for your response. Attached the screenshot. hope it will work now
This comment was minimized by the moderator on the site
Hi Yoni,Sorry for the inconvenience. The screenshot you uploaded is still not shown on the page. You need to save the screenshot on your disk in advance and then uplode it via the "Upload files" button. See the attached screenshot.
This comment was minimized by the moderator on the site
will, thank you is not enugh :::: alot of thank you then ;;;;; that worked like magic :)
This comment was minimized by the moderator on the site
Yeah, basically completely useless.  Want the cell to auto-complete when typing in a cell using list data validation.Tried this, and now I have to start over from scratch because I can't Undo it.  Thanks.Also loaded with syntax errors.
This comment was minimized by the moderator on the site
It works as it should be except for two things, first, there is no validation after insertion. i.e. if I typed anything at the combo then clicked enter it will accept the typed value while it should not do this since the data validation is being used to prevent such behaviors and make sure that the entered data is from selected range. Second, at the data validation list, sometimes I use big range with empty cells and select ignore empty at validation list but the combo takes all the range and shows it, will be nice to remove the empty cells from the combo range.
Thanks & hope you can implement these things to make it perfect.
This comment was minimized by the moderator on the site
Hi, AhmedThe VBA below helps to solve the problem of blank cells. Since the Combo box accepts the value that are not in the list, we still can't find a way to solve this problem. Sorry for the inconvenience.
<div data-tag="code">Private Sub Worksheet_SelectionChange(ByVal Target As Range)
'Update by Extendoffice: 2021/11/05
Dim xCombox As OLEObject
Dim xStr As String
Dim xWs As Worksheet
Dim xArr, xArr1
Dim xRg As Range
Dim xSrc As Variant
Dim xI, xJ, xIndex, xCount As Integer

Set xWs = Application.ActiveSheet
On Error Resume Next
Set xCombox = xWs.OLEObjects("TempCombo")
With xCombox
.ListFillRange = ""
.LinkedCell = ""
.Visible = False
End With
If Target.Validation.Type = 3 Then
Target.Validation.InCellDropdown = False
Cancel = True
xStr = Target.Validation.Formula1
xStr = Right(xStr, Len(xStr) - 1)
If xStr = "" Then Exit Sub
Set xRg = Range(xStr)
If xRg Is Nothing Then
xArr1 = Split(xStr, ",")
Else
ReDim xArr1(0 To xRg.Count - 1)
For xI = 0 To xRg.Count - 1
xArr1(xI) = xRg.Item(xI + 1).Value
Next
End If
xI = 0
xCount = UBound(xArr1) + 1
For xJ = 0 To UBound(xArr1)
If Replace(xArr1(xJ), " ", "") = "" Then xCount = xCount - 1
Next
ReDim xArr(0 To xCount - 1)
xIndex = 0
For xJ = 0 To UBound(xArr1)
If Replace(xArr1(xJ), " ", "") <> "" Then
xArr(xIndex) = xArr1(xJ)
xIndex = xIndex + 1
End If
Next
xStr = ""
With xCombox
.Visible = True
.Left = Target.Left
.Top = Target.Top
.Width = Target.Width + 5
.Height = Target.Height + 5
.ListFillRange = xStr
If .ListFillRange = "" Then
'xArr = Split(xStr, ",")
Me.TempCombo.List = xArr
End If
.LinkedCell = Target.Address
End With
xCombox.Activate
Me.TempCombo.DropDown
End If
End Sub
Private Sub TempCombo_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
Select Case KeyCode
Case 9
Application.ActiveCell.Offset(0, 1).Activate
Case 13
Application.ActiveCell.Offset(1, 0).Activate
End Select
End Sub
This comment was minimized by the moderator on the site
Hi Crystal,
I am working with the combo box (The VBA code from 2021/11/05). It is working great and so useful! thanks a lot.
I found the source of my problem. There was a line of freeze panes which override the combo box.
The only problem now is that the Undo is not working. Any idea?
Thanks in advanced,
Yoni
This comment was minimized by the moderator on the site
Hi,
The code does not support Undo. Sorry for the inconvenience.
This comment was minimized by the moderator on the site
Thanks. Maybe do you know why Worksheet_Change event is not firing once I choose value from the combo box?
This comment was minimized by the moderator on the site
Hi, could you please doublecheck this code, when I use it instead of the dropdown list appearing, the source for the dropdown appears instead. This is the exact function I want, could you please fix it.
This comment was minimized by the moderator on the site
If you use a named range or something similar, like I have with a table column, it will display the named range name instead of the values in that named range. To get what you want, you need to change the xStr to display the worksheet range of that named range, since the .ListFillRange does not take in named ranges directly. This should accomplish it : dim RangeAddress as String: RangeAddress = Range(YourNamedRange).addressand then make the xStr something like this: xStr = "YourWorksheetNameWithTheNamedRangeInIt!" & RangeAddress (important: add the '!' for the sheet reference)
This will make your xStr look something like: NamedRangeSheet!$A$1:$A$5
xStr = Right(xStr, Len(xStr) - 1)

If .ListFillRange = "" Then
xArr = Split(xStr, ",")
Me.TempCombo.List = xArr
End If

with these adjustments your combobox should display the list values instead of the source
This comment was minimized by the moderator on the site
Hi Syu,Sorry I don't quite understand your description. Can you try to be more specific of it?After applying the VBA code mentioned in the above method, when the cell with the data validation drop-down list is checked, the drop-down list turn into a combo box, and then all the items in the list are listed. 
This comment was minimized by the moderator on the site
do you have an example file please?
This comment was minimized by the moderator on the site
Hello. The code is very cool. Please make sure that the formula "INDIRECT" is carried out and displayed. It is very necessary
This comment was minimized by the moderator on the site
The code is not working for a validation list which is created by vba code and the source is a named range
There are no comments posted here yet
Load More
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations