跳到主要內容

如何在Excel中設置/顯示下拉列表的預選值?

默認情況下,您創建的常規下拉列表在從列表中選擇一個值之前顯示為空白,但是在某些情況下,您可能希望在用戶從下拉列表中選擇一個之前顯示或設置下拉列表的預選值/默認值列表如下所示。 本文可以為您提供幫助。


箭頭藍色右氣泡 使用公式為下拉列表設置默認值(預選值)

要為下拉列表設置默認值,您需要先創建一個常規下拉列表,然後使用公式。

1.創建一個下拉列表。 選擇要放置下拉列表的單元格或範圍,這裡是K1,然後單擊 數據 > 數據驗證。 看截圖:
doc顯示預選值下拉列表2

2.然後在 數據驗證 對話框下 設定 標籤,選擇 名單 列表,然後在下拉列表中選擇要顯示的值 資源 文本框。 看截圖:
doc顯示預選值下拉列表3

3。 然後點擊 錯誤警報 在標籤 數據驗證 對話框,然後取消選中 輸入無效數據後顯示錯誤警報 選項。 看截圖:
doc顯示預選值下拉列表4

4。 點擊 OK 關閉對話框,然後轉到下拉列表,然後鍵入此公式 = IF(J1 =“”,“ --select--”) 進去,然後按 Enter 鍵。 看截圖:
doc顯示預選值下拉列表5

小提示: 在公式, J1 是K1旁邊的空白單元格,請確保該單元格為空白,然後“- 選擇 - ”是您要顯示的預選值,您可以根據需要進行更改。

5.然後,保持下拉列表單元處於選中狀態,然後單擊 數據 > 數據驗證 顯示 數據驗證 再次對話,然後轉到 錯誤警報 標籤,並檢查 輸入無效數據後顯示錯誤警報 選項回來。 看截圖:
doc顯示預選值下拉列表6

7。 點擊 OK,現在用戶在從下拉列表中選擇值之前,在帶有下拉列表的指定單元格中顯示了一個默認值。
doc顯示預選值下拉列表7

注意: 從下拉列表中選擇一個值時,默認值消失。
doc顯示預選值下拉列表8


最佳辦公生產力工具

🤖 Kutools 人工智慧助手:基於以下內容徹底改變數據分析: 智慧執行   |  生成代碼  |  建立自訂公式  |  分析數據並產生圖表  |  呼叫 Kutools 函數...
熱門特色: 尋找、突出顯示或識別重複項   |  刪除空白行   |  合併列或儲存格而不遺失數據   |   沒有公式的回合 ...
超級查詢: 多條件VLookup    多值VLookup  |   跨多個工作表的 VLookup   |   模糊查詢 ....
高級下拉列表: 快速建立下拉列表   |  依賴下拉列表   |  多選下拉列表 ....
欄目經理: 新增特定數量的列  |  移動列  |  切換隱藏列的可見性狀態  |  比較範圍和列 ...
特色功能: 網格焦點   |  設計圖   |   大方程式酒吧    工作簿和工作表管理器   |  資源庫 (自動文字)   |  日期選擇器   |  合併工作表   |  加密/解密單元格    按清單發送電子郵件   |  超級濾鏡   |   特殊過濾器 (過濾粗體/斜體/刪除線...)...
前 15 個工具集12 文本 工具 (添加文本, 刪除字符,...)   |   50+ 圖表 類型 (甘特圖,...)   |   40+ 實用 公式 (根據生日計算年齡,...)   |   19 插入 工具 (插入二維碼, 從路徑插入圖片,...)   |   12 轉化 工具 (數字到單詞, 貨幣兌換,...)   |   7 合併與拆分 工具 (高級合併行, 分裂細胞,...)   |   ... 和更多

使用 Kutools for Excel 增強您的 Excel 技能,體驗前所未有的效率。 Kutools for Excel 提供了 300 多種進階功能來提高生產力並節省時間。  點擊此處獲取您最需要的功能...

產品描述


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

  • 在Word,Excel,PowerPoint中啟用選項卡式編輯和閱讀,發布者,Access,Visio和Project。
  • 在同一窗口的新選項卡中而不是在新窗口中打開並創建多個文檔。
  • 將您的工作效率提高 50%,每天為您減少數百次鼠標點擊!
Comments (15)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Hi,

How to count (D71) conditionally formatted RED color cell (D40:D70)?

Pls guide...

Thanks.
This comment was minimized by the moderator on the site
Hi,

How to make default value (UP) for certain range of column (C40:C70) only in the below code? Add what command?

Private Sub Worksheet_Change(ByVal Target As Range)
‘Updated by ARUN
Dim xObjV As Validation
On Error Resume Next
Set xObjV = Target.Validation
If xObjV.Type = xlValidateList Then
If IsEmpty(Target.Value) Then Target.Value = “UP”
End If
End Sub

Pls guide…

Thanks.
This comment was minimized by the moderator on the site
Try this code
Private Sub Worksheet_Change(ByVal Target As Range)
    'Updated by ExtendOffice
    Dim xObjV As Validation
    On Error Resume Next
    Set xObjV = Target.Validation
    
    'Check if the target is within C40:C70
    If Not Intersect(Target, Range("C40:C70")) Is Nothing Then
        If xObjV.Type = xlValidateList Then
            If IsEmpty(Target.Value) Then Target.Value = "UP"
        End If
    End If
End Sub
This comment was minimized by the moderator on the site
Hi,

Its working...

Thanks
This comment was minimized by the moderator on the site
Hello, How can I get defined value limit in excel dropdown menu, like I want to Enter Apple in product against three name and it should not put 4th entry and give error if i do so, any solution please.
This comment was minimized by the moderator on the site
Sorry, I do not understand your question, could you describe with more details or upload a file to describe it?
This comment was minimized by the moderator on the site
Hello, How can I get defined value limit in excel dropdown menu, like I want to Enter Apple in product against three name and it should not put 4th entry and give error if i do so, any soluition please.
This comment was minimized by the moderator on the site
hello, my data is about names and phone numbers. can make it if two names selected in one cells using data validations, the particular name which their name as selected, their phone numbers will be shown next to it.

help me!
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
The idea is nice, but my problem is that if the dropdown value is deleted, it doesn't revert to the default.
This comment was minimized by the moderator on the site
I also have the same issue , please reply if you solved it
This comment was minimized by the moderator on the site
Exactly!!! I'm having the same issue, have you found a solution?
This comment was minimized by the moderator on the site
You can insert the function in that specific cell using VBA, make sure you call the insert function when workbook is opening.
This comment was minimized by the moderator on the site
Only works if you speak VBA, not all of us code.
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations