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

ドロップダウンリストの最初の項目を空白ではなく表示するにはどうすればよいですか?

ドキュメントのドロップダウンリストのデフォルトはトップ1です

ワークシートのドロップダウンリストは、データ入力を簡単にするのに役立つ場合があります。項目をXNUMXつずつ入力せずに選択するだけです。 ただし、ドロップダウンリストをクリックすると、次のスクリーンショットに示すように、最初のデータ項目ではなく最初に空白の項目にジャンプする場合があります。これは、リストの最後にあるソースデータを削除したことが原因である可能性があります。 空白のデータ検証セルごとに長いリストの一番上にスクロールして戻る必要があるのは面倒かもしれません。 この記事では、ドロップダウンリストの最初の項目を常に表示する方法について説明します。

データ検証機能を使用して、ドロップダウンリストの最初の項目を空白ではなく表示する

ドロップダウンリストの最初の項目をVBAコードで空白ではなく自動的に表示する


矢印青い右バブル データ検証機能を使用して、ドロップダウンリストの最初の項目を空白ではなく表示する

実際、この仕事を達成するには、ドロップダウンリストを作成するときに特定の数式を適用する必要があります。次のようにしてください。

1。 ドロップダウンリストを挿入するセルを選択し、をクリックします 且つ > データ検証 > データ検証、スクリーンショットを参照してください:

ドキュメントのドロップダウンリストのデフォルトはトップ2です

2。 飛び出した データ検証 ダイアログボックス、下 設定 タブを選択 リスト 次を許可します。 セクションをクリックし、次の式を入力します。 = OFFSET(Sheet3!$ A $ 1,0,0、COUNTA(Sheet3!$ A:$ A)-1,1)ソース テキストボックス、スクリーンショットを参照:

Note:この式では、 Sheet3 ワークシートにはソースデータリストが含まれています。 A1 リストの最初のセル値です。

ドキュメントのドロップダウンリストのデフォルトはトップ3です

3。 次に、をクリックします OK ボタンをクリックすると、ドロップダウンリストのセルをクリックすると、ソースデータの最後にセル値が削除されているかどうかに関係なく、最初のデータ項目が常に上部に表示されます。スクリーンショットを参照してください。

ドキュメントのドロップダウンリストのデフォルトはトップ4です


矢印青い右バブル ドロップダウンリストの最初の項目をVBAコードで空白ではなく自動的に表示する

ここでは、データ検証セルをクリックしたときにドロップダウンリストの最初の項目を自動的に表示するのに役立つVBAコードを紹介することもできます。

1。 ドロップダウンリストを挿入した後、ドロップダウンリストを含むワークシートタブを選択し、右クリックして選択します コードを表示 コンテキストメニューからに移動します アプリケーション向け Microsoft Visual Basic ウィンドウをクリックし、次のコードをコピーしてモジュールに貼り付けます。

VBAコード:ドロップダウンリストの最初のデータ項目を自動的に表示します。

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
'Updateby Extendoffice 20160725
    Dim xFormula As String
    On Error GoTo Out:
    xFormula = Target.Cells(1).Validation.Formula1
    If Left(xFormula, 1) = "=" Then
        Target.Cells(1) = Range(Mid(xFormula, 1)).Cells(1).Value
    End If
Out:
End Sub

ドキュメントのドロップダウンリストのデフォルトはトップ5です

2。 次に、コードウィンドウを保存して閉じます。ドロップダウンリストのセルをクリックすると、最初のデータ項目が一度に表示されます。

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

🤖 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 (10)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
=OFFSET(Sheet3!$A$1,0,0,COUNTA(Sheet3!$A:$A)+2-1,1) I added +2 to the equation and that worked for me.
This comment was minimized by the moderator on the site
For the VDA code, how can I have only a certain cell range show the first item in the drop down list? Thank you in advance.
This comment was minimized by the moderator on the site
Hi, Akrupa,To solve your problem, maybe the following VBA code can help you:

<div data-tag="code">Private Sub Worksheet_SelectionChange(ByVal Target As Range)
'Updateby Extendoffice 20211206
Dim xFormula As String
Dim xRg As Range
Dim xStr As String
Dim xIndex As Integer
xIndex = 2 'Here indicates the cell number of the original data,for example,the original data is A1:A10, to display the A2 cell value, please write 2 here.
On Error GoTo Out:
xFormula = Target.Cells(1).Validation.Formula1
If Left(xFormula, 1) = "=" Then
If Target.Value <> "" Then Exit Sub
xStr = Mid(xFormula, 2)
Set xRg = Application.Range(xStr)
Target.Cells(1) = xRg.Cells(xIndex).Value
End If
Out:
End Sub
Please try, hope it can help you!
This comment was minimized by the moderator on the site
Better but not quite. Using the =OFFSET(Sheet3!$A$1,0,0,COUNTA(Sheet3!$A:$A)-1,1) method eliminates the blanks but still starts you at the bottom of the very long list. I want it to start at the top of the list.
This comment was minimized by the moderator on the site
Once again, you save the day! Thanks!
This comment was minimized by the moderator on the site
Doesn't work for me. I keep getting an error message that says, "There's a problem with this formula. Not trying to type a formula? When the first character is an equal (+) or minus (-) sign, Exel thinks it's a formula.... To get around this, type an apostrophe (') first..."
This comment was minimized by the moderator on the site
Hello!

How can I set a data validation list such that if the drop down value in the cell is deleted, the cell will automatically show a default value (i.e. "-Select-")?

For example, I have a worksheet with multiple drop down lists that I want to show a default value of "-Select-" once the sheet is opened. A user will select values from the lists that will impact the result of calculations throughout the entire spreadsheet. A user may accidentally "delete" the cell contents of the lists. If this happens, rather than the cell becoming blank, I want the cell to show a default value of "-Select-". This scenario occurs in multiple random locations throughout the spreadsheet, not just in one localized place.

I was able to find the following VBA code so far, but it only applies the concept over a range, rather than just individual cells that contain drop down lists. The problem with what I have coded so far is that every single blank cell in the range ends up with "-Select-" in it. Some of the lists are in ranges, but some are also scattered throughout the sheet. The problem I'm having with my current code is that every single blank cell in the range ends up with "-Select-" in it. I'm trying to get this to apply over the entire worksheet to ONLY cells that are drop down lists.

Is what I'm trying to accomplish even possible?

Example file can be found here:
https://drive.google.com/file/d/1VoO8VgFs3IJ0ALwqfk0i8gt69UE4vEKW/view?usp=sharing

Example code:

Option Explicit

Private Sub Worksheet_Change(ByVal Target As Range)
Dim cel As Range
' If Target.Cells.Count > 1 Then Exit Sub 'turning this off allows multiple cells to be selected and deleted at the same time
If Not Intersect(Target, Range("f2:p17")) Is Nothing Then
For Each cel In Range("f2:p17")
Application.EnableEvents = False
If IsEmpty(cel.Value) Then cel.Value = "-Select-"
Next cel
End If
Application.EnableEvents = True
End Sub


Thanks in advance!
This comment was minimized by the moderator on the site
How can I set a data validation list such that if the drop down value in the cell is deleted, the cell will automatically show the a default value (i.e. "-Select-")?

For example, I have a worksheet with multiple drop down lists that I want to show a default value of "-Select-" once the sheet is opened. A user will select values from the lists that will impact the result of calculations throughout the entire spreadsheet. A user may accidentally "delete" the cell contents. If this happens, rather than the cell becoming blank, I want the cell to show a default value of "-Select-". This scenario occurs in multiple random locations throughout the spreadsheet, not just in one localized place.

I was able to come up with the following VBA code so far, but I've only figured out how to apply the concept over a range, rather than just cells that contain a drop down list. The problem with what I have coded so far is that every single blank cell in the range ends up with "-Select-" in it.

Option Explicit

Private Sub Worksheet_Change(ByVal Target As Range)
Dim cel As Range
' If Target.Cells.Count > 1 Then Exit Sub
If Not Intersect(Target, Range("f2:p17")) Is Nothing Then
For Each cel In Range("f2:p17")
Application.EnableEvents = False
If IsEmpty(cel.Value) Then cel.Value = "-Select-"
Next cel
End If
Application.EnableEvents = True
End Sub
This comment was minimized by the moderator on the site
select the cell in which you have put the listitem
the range for the listitem is "Opleiding"
in your VBA code:

selection.Value = Range("opleiding").Cells(2, 1)

the result is that the selected item of the listItem is the second item in the range "Opleiding"
This comment was minimized by the moderator on the site
After scroll down select to cells numeric data not come in series only first cell data come select 1,2 different cells and scroll down value not coming 1,2,3,4,5....... only first cell value coming 1,1,1,1,....
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations