วิธีเติมข้อความอัตโนมัติเมื่อพิมพ์ในรายการแบบเลื่อนลงของ Excel
หากคุณมีรายการแบบเลื่อนลงการตรวจสอบข้อมูลที่มีรายการขนาดใหญ่คุณจะต้องเลื่อนขึ้นและลงในรายการเพื่อค้นหาคำที่เหมาะสมหรือพิมพ์ทั้งคำลงในกล่องรายการโดยตรง หากมีวิธีการอนุญาตให้กรอกอัตโนมัติเมื่อพิมพ์ตัวอักษรตัวแรกในรายการแบบเลื่อนลงทุกอย่างจะง่ายขึ้น บทช่วยสอนนี้จะให้วิธี VBA เพื่อช่วยให้คุณบรรลุ
เติมข้อความอัตโนมัติเมื่อพิมพ์ในรายการแบบเลื่อนลงด้วยรหัส VBA
บทแนะนำเพิ่มเติมสำหรับรายการแบบเลื่อนลง ...
เติมข้อความอัตโนมัติเมื่อพิมพ์ในรายการแบบเลื่อนลงด้วยรหัส VBA
โปรดทำดังนี้เพื่อทำการเติมข้อความอัตโนมัติในรายการแบบหล่นลงหลังจากพิมพ์ตัวอักษรที่เกี่ยวข้องในเซลล์
ประการแรกคุณต้องแทรกกล่องคำสั่งผสมลงในแผ่นงานและเปลี่ยนคุณสมบัติ
1. เปิดแผ่นงานที่มีเซลล์รายการแบบหล่นลงที่คุณต้องการให้เติมข้อความอัตโนมัติ
2. ก่อนแทรกกล่องคำสั่งผสมคุณต้องเพิ่มแท็บนักพัฒนาลงในริบบิ้นของ Excel หากแท็บนักพัฒนาปรากฏบน Ribbon ของคุณ เปลี่ยนเป็นขั้นตอนที่ 3. มิฉะนั้นให้ดำเนินการดังนี้: คลิก เนื้อไม่มีมัน > Options เพื่อเปิด Options หน้าต่าง. ในเรื่องนี้ ตัวเลือก Excel หน้าต่างคลิก ปรับแต่งริบบิ้น ในบานหน้าต่างด้านซ้ายตรวจสอบไฟล์ ผู้พัฒนา จากนั้นคลิกที่ไฟล์ OK ปุ่ม. ดูภาพหน้าจอ:
3 คลิก ผู้พัฒนา > สิ่งที่ใส่เข้าไป > กล่องคำสั่งผสม (ActiveX Control).
4. วาดกล่องคำสั่งผสมในแผ่นงานปัจจุบัน คลิกขวาจากนั้นเลือก อสังหาริมทรัพย์ จากเมนูคลิกขวา
5 ใน อสังหาริมทรัพย์ โปรดแทนที่ข้อความเดิมในไฟล์ (ชื่อ) ฟิลด์ด้วย TempCombo
6 ปิดกล้อง โหมดการออกแบบ โดยคลิกที่ ผู้พัฒนา > โหมดการออกแบบ
จากนั้นใช้รหัส VBA ด้านล่าง
7. คลิกขวาที่แท็บแผ่นงานปัจจุบันแล้วคลิก ดูรหัส จากเมนูบริบท ดูภาพหน้าจอ:
8. ในการเปิด Microsoft Visual Basic สำหรับแอปพลิเคชัน โปรดคัดลอกและวางโค้ด VBA ด้านล่างลงในหน้าต่าง Code ของแผ่นงาน
รหัส 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
9 กด อื่น ๆ + Q พร้อมกันเพื่อปิดไฟล์ แอปพลิเคชัน Microsoft Visual Basic หน้าต่าง
จากนี้ไปเมื่อคลิกที่เซลล์รายการแบบหล่นลงรายการแบบหล่นลงจะแจ้งโดยอัตโนมัติ คุณสามารถเริ่มพิมพ์ตัวอักษรเพื่อทำให้รายการที่เกี่ยวข้องเสร็จสมบูรณ์โดยอัตโนมัติในเซลล์ที่เลือก ดูภาพหน้าจอ:
บันทึก: รหัสนี้ใช้ไม่ได้กับเซลล์ที่ผสาน
สร้างรายการแบบหล่นลงได้อย่างง่ายดายด้วยช่องทำเครื่องหมายใน Excel:
แพทเทิร์น รายการแบบหล่นลงพร้อมกล่องกาเครื่องหมาย ประโยชน์ของ Kutools สำหรับ Excel สามารถช่วยให้คุณสร้างรายการแบบหล่นลงได้อย่างง่ายดายด้วยช่องทำเครื่องหมายในช่วงที่ระบุแผ่นงานปัจจุบันสมุดงานปัจจุบันหรือสมุดงานที่เปิดทั้งหมดตามความต้องการของคุณ
ดาวน์โหลดและทดลองใช้เลย! (เส้นทางฟรี 30 วัน)
บทความที่เกี่ยวข้อง:
วิธีสร้างรายการแบบหล่นลงพร้อมช่องทำเครื่องหมายหลายช่องใน Excel
ผู้ใช้ Excel จำนวนมากมักจะสร้างรายการแบบหล่นลงโดยมีช่องทำเครื่องหมายหลายช่องเพื่อเลือกหลายรายการจากรายการต่อครั้ง จริงๆแล้วคุณไม่สามารถสร้างรายการที่มีช่องทำเครื่องหมายหลายช่องด้วยการตรวจสอบข้อมูล ในบทช่วยสอนนี้เราจะแสดงวิธีการสองวิธีในการสร้างรายการแบบหล่นลงพร้อมช่องทำเครื่องหมายหลายช่องใน Excel บทแนะนำนี้มีวิธีการแก้ปัญหา
สร้างรายการแบบหล่นลงจากสมุดงานอื่นใน Excel
มันค่อนข้างง่ายในการสร้างรายการแบบเลื่อนลงสำหรับการตรวจสอบข้อมูลระหว่างแผ่นงานภายในสมุดงาน แต่ถ้าข้อมูลรายการที่คุณต้องการสำหรับการตรวจสอบข้อมูลอยู่ในสมุดงานอื่นคุณจะทำอย่างไร? ในบทช่วยสอนนี้คุณจะได้เรียนรู้วิธีสร้างรายการลดลงจากสมุดงานอื่นใน Excel โดยละเอียด
สร้างรายการดรอปดาวน์ที่ค้นหาได้ใน Excel
สำหรับรายการแบบหล่นลงที่มีค่ามากมายการค้นหารายการที่เหมาะสมไม่ใช่เรื่องง่าย ก่อนหน้านี้เราได้แนะนำวิธีการกรอกรายการแบบเลื่อนลงโดยอัตโนมัติเมื่อป้อนตัวอักษรตัวแรกลงในช่องแบบเลื่อนลง นอกจากฟังก์ชันเติมข้อความอัตโนมัติแล้วคุณยังสามารถค้นหารายการแบบหล่นลงได้เพื่อเพิ่มประสิทธิภาพในการทำงานในการค้นหาค่าที่เหมาะสมในรายการแบบเลื่อนลง หากต้องการค้นหารายการแบบหล่นลงให้ลองใช้วิธีการในบทช่วยสอนนี้
เติมข้อมูลเซลล์อื่นโดยอัตโนมัติเมื่อเลือกค่าในรายการแบบเลื่อนลงของ Excel
สมมติว่าคุณได้สร้างรายการแบบหล่นลงตามค่าในช่วงเซลล์ B8: B14 เมื่อคุณเลือกค่าใด ๆ ในรายการแบบหล่นลงคุณต้องการให้ค่าที่เกี่ยวข้องในช่วงเซลล์ C8: C14 ถูกเติมโดยอัตโนมัติในเซลล์ที่เลือก สำหรับการแก้ปัญหาวิธีการในบทช่วยสอนนี้จะช่วยคุณได้
เครื่องมือเพิ่มประสิทธิภาพการทำงานในสำนักงานที่ดีที่สุด
Kutools สำหรับ Excel ช่วยแก้ปัญหาส่วนใหญ่ของคุณและเพิ่มผลผลิตของคุณได้ถึง 80%
- นำมาใช้ใหม่: ใส่อย่างรวดเร็ว สูตรที่ซับซ้อนแผนภูมิ และสิ่งที่คุณเคยใช้มาก่อน เข้ารหัสเซลล์ ด้วยรหัสผ่าน; สร้างรายชื่อผู้รับจดหมาย และส่งอีเมล ...
- Super Formula Bar (แก้ไขข้อความและสูตรหลายบรรทัดได้อย่างง่ายดาย); การอ่านเค้าโครง (อ่านและแก้ไขเซลล์จำนวนมากได้อย่างง่ายดาย); วางลงในช่วงที่กรองแล้ว...
- ผสานเซลล์ / แถว / คอลัมน์ โดยไม่สูญเสียข้อมูล แยกเนื้อหาของเซลล์ รวมแถว / คอลัมน์ที่ซ้ำกัน... ป้องกันเซลล์ซ้ำ; เปรียบเทียบช่วง...
- เลือกซ้ำหรือไม่ซ้ำ แถว; เลือกแถวว่าง (เซลล์ทั้งหมดว่างเปล่า); Super Find และ Fuzzy Find ในสมุดงานจำนวนมาก สุ่มเลือก ...
- สำเนาถูกต้อง หลายเซลล์โดยไม่เปลี่ยนการอ้างอิงสูตร สร้างการอ้างอิงอัตโนมัติ ถึงหลายแผ่น ใส่สัญลักษณ์แสดงหัวข้อย่อย, กล่องกาเครื่องหมายและอื่น ๆ ...
- แยกข้อความ, เพิ่มข้อความ, ลบตามตำแหน่ง, ลบ Space; สร้างและพิมพ์ผลรวมย่อยของเพจ แปลงระหว่างเนื้อหาของเซลล์และความคิดเห็น...
- ซุปเปอร์ฟิลเตอร์ (บันทึกและใช้โครงร่างตัวกรองกับแผ่นงานอื่น ๆ ); การเรียงลำดับขั้นสูง ตามเดือน / สัปดาห์ / วันความถี่และอื่น ๆ ตัวกรองพิเศษ โดยตัวหนาตัวเอียง ...
- รวมสมุดงานและแผ่นงาน; ผสานตารางตามคอลัมน์สำคัญ แยกข้อมูลออกเป็นหลายแผ่น; Batch แปลง xls, xlsx และ PDF...
- คุณสมบัติที่ทรงพลังมากกว่า 300 รายการ. รองรับ Office / Excel 2007-2019 และ 365 รองรับทุกภาษา ใช้งานง่ายในองค์กรหรือองค์กรของคุณ ทดลองใช้ฟรี 30 วันเต็ม รับประกันคืนเงิน 60 วัน

แท็บ Office นำอินเทอร์เฟซแบบแท็บมาที่ Office และทำให้งานของคุณง่ายขึ้นมาก
- เปิดใช้งานการแก้ไขและอ่านแบบแท็บใน Word, Excel, PowerPoint, ผู้จัดพิมพ์, Access, Visio และโครงการ
- เปิดและสร้างเอกสารหลายรายการในแท็บใหม่ของหน้าต่างเดียวกันแทนที่จะเป็นในหน้าต่างใหม่
- เพิ่มผลผลิตของคุณ 50% และลดการคลิกเมาส์หลายร้อยครั้งให้คุณทุกวัน!

You are guest
or post as a guest, but your post won't be published automatically.
-
To post as a guest, your comment is unpublished.· 12 days agohi, thanks for your code. I would like to autocomplete and make multiple selections in a drop down list. Can you help me please?, thank you
-
To post as a guest, your comment is unpublished.
-
To post as a guest, your comment is unpublished.Hello, is there a chance to add dependency to select date and in the next column to the proposed choices?
-
To post as a guest, your comment is unpublished.como hago para agregar esta función=INDIRECTO("tabla1[columna]")al código
-
To post as a guest, your comment is unpublished.I tried to use this method. I added the code. After that I add the range needed. Looks all fine. Then I test and the combobox dissapears directly after filling it. So the code works, but its not usable. What do I do wrong?Kind regards, Danielle
-
To post as a guest, your comment is unpublished.
-
To post as a guest, your comment is unpublished.Hi I have some difficulties with my excel work. I would like to know if there is a method to autofill the cell I desire?Example1 = san pedro2 = santa rosa3 = calamba4 = san pabloand so on.I have a list with correspoding numbers. If I input number 1 in Cell A5 I would like it to automatically fill the Cell B5 with its corresponding list name (san pedro) and if I input 3 in A5, B5 will be = calamba.thank you. for the help, Im having trouble to find a solution to this hope to find answers.Thank you and God Bless.
-
To post as a guest, your comment is unpublished.Hi Guys,
I have made 2 different drop down list searchable in 1 sheet, the fist is working well but the second drop down list is showing me the formula of indirect as the second drop down list is indirect of the first. I have apply the VBA with combo and so on but still the second list is showing me the formula. how to I fix this? -
To post as a guest, your comment is unpublished.Hi Guys,
I have made 2 different drop down list searchable in 1 sheet, the fist is working well but the second drop down list is showing me the formula of indirect as the second drop down list is indirect of the first. I have apply the VBA with combo and so on but still the second list is showing me the formula. how to I fix this?
-
To post as a guest, your comment is unpublished.Hello, I have a problem with this method and I already use a list validated with an indirect function to refer to the range of a table and when applying this macro it shows me only the indirect formula in the list! How could I solve this problem?
-
To post as a guest, your comment is unpublished.
-
To post as a guest, your comment is unpublished.Hello, is it possible to replicate this in a complete column? I mean that each individual row of a column has this possibility or at least 1000 rows in a simple way. Thank you!
-
To post as a guest, your comment is unpublished.If you use this method with one combobox/sheet i guess it's flawless.
I used this method with three comboboxes on one sheet with 3 different ListFillRange.
Dropdown keep showing up on different combobox than what i'm typing in.
1. I type and select correctly from the first.
2. When i go to second combo, the third dropdown pops up.(I have to select the"", as it is still empty)
then i can search my second combobox.
3. When i go to the third, the first dropdown pops up, I reselect the only item(as there is only one that was already selected in the first step)
After this i can add the content in the third dropdown.
All subs are on sheet1's vba window.
Now i'm trying to spit code in different modules, but can't really make it work.
Search works, but i always have to push the dropdown arrow to see available results to select. Dropdown doesn't pop up at all.
using 365, but i have to make "sheet" work on excel 2010 -
To post as a guest, your comment is unpublished.The command works when first applied. But after saving the file, when i reopen it the drop down itself disappears.
-
To post as a guest, your comment is unpublished.Hi Rohit,
After applying the code, please save the workbook as an Excel Macro-Enabled Workbook before closing the file.
-
-
To post as a guest, your comment is unpublished.I get an error message (1004) - the debug highlights ‘If Target.Validation.Type =3 Then’
for info .. I use excel 2010
-
To post as a guest, your comment is unpublished.Hi,
I tried the VBA in Excel 2010 and it works well.
The drop down list should be data validation drop-down list which is created by clicking Data > Data Validation....-
To post as a guest, your comment is unpublished.It's work in cell with list but when i move or tap or select any cell with no list ..the up message talked you about always show..
-
-
-
To post as a guest, your comment is unpublished.Hi! Thanks for this code!
I'm getting a compile error saying "variable not defined", it highlights the "cancel = true" line
-
To post as a guest, your comment is unpublished.Hi Carlos,
Which Excel version are you using?-
To post as a guest, your comment is unpublished.
-
To post as a guest, your comment is unpublished.
-
-
-
To post as a guest, your comment is unpublished.
-
To post as a guest, your comment is unpublished.Hi,
Is it possible to show the matches with the caracter your typping using this code and format of combox?
Example:
You have a list with Onion, Black Onion, Green Onion, Red Onion...
And in the combox you type: "On", so the drop down list show all the values existing on the list that matchs with "On".
Thanks -
To post as a guest, your comment is unpublished.When I applied this code to my worksheet, the Undo function is disabled (but only for this sheet in the workbook) -- is there a way to fix this so that undo can still be used?
-
To post as a guest, your comment is unpublished.Hi Reinaldo Yajure,
Please apply the below VBA code. The problem is fixed. Sorry for the inconvenience.
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
'Update by Extendoffice: 2020/05/19
Dim xCombox As OLEObject
Dim xStr As String
Dim xWs As Worksheet
Dim xArr
Set xWs = Application.ActiveSheet
On Error Resume Next
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 xCombox = xWs.OLEObjects("TempCombo")
With xCombox
.ListFillRange = ""
.LinkedCell = ""
.Visible = False
End With
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
-
To post as a guest, your comment is unpublished.Hi there, this is a great solution, but for some reason, in the original code, the combox was hidden when the cell with the data validation was not active, and only visible when the cell was selected.With this code, we get undo back, which is perfect, but the combox does not auto-hide again when you click off.Do you have a solution for this?Thanks,Alistair
-
-
-
To post as a guest, your comment is unpublished.is there any way to increase the list size as it is showing up only 10 line items as i have 12 lines
-
To post as a guest, your comment is unpublished.How can I Use Tab/Arrows/Enter to move to another cell once the current cell is filled? Thanks
-
To post as a guest, your comment is unpublished.
-
To post as a guest, your comment is unpublished.Hi Guys, are you able to share a code which i can use so that the autocomplete is used on the same column i.e H in every sheet within the workbook.
-
To post as a guest, your comment is unpublished.Hi,
If you only want the column H to be affected, please try the below VBA code. But it is only available in one worksheet. For multiple sheets, you need to add the code to each sheet code window. Hope I can help.
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
'Update by Extendoffice: 2019/8/14
Dim xCombox As OLEObject
Dim xStr As String
Dim xWs As Worksheet
Dim xArr
Dim xRgStr As String
Dim xRg As Range
xRgStr = "H:H"
Set xWs = Application.ActiveSheet
On Error Resume Next
Set xCombox = xWs.OLEObjects("TempCombo")
With xCombox
.ListFillRange = ""
.LinkedCell = ""
.Visible = False
End With
Set xRg = Intersect(Range(xRgStr), Target)
If xRg Is Nothing Then Exit Sub
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
-
-
To post as a guest, your comment is unpublished.
-
To post as a guest, your comment is unpublished.Woooooooowwwwww very useful, thankyou for sharing, god bless you
-
To post as a guest, your comment is unpublished.Love this! Thanks so much. Got a small issue though. I like to tab from one cell to the next, but when I get to the cell with the drop down list, I can tab into the cell with no problem, but once I'm in, it won't let me tab back out. I have to physically move the mouse over and click into the next cell. Any fix for this? Kind of disrupts my rhythm, which is why I loved this autocomplete function in the first place. ;o)
-
To post as a guest, your comment is unpublished.This is a great find, however, I have one little issue: I like to tab through the cells as I am entering data. I can tab into the cell with the drop down menu just fine, but once I'm in that cell, it stops me from exiting the cell with a tab. I have to physically move the mouse to the next cell and click on it. Is there a fix to be able to simply tab in and tab out of the autocomplete cell? Thanks.
-
To post as a guest, your comment is unpublished.I am using this code and a data validation with drop down lists for easy acces to what i need because i need the data to remain in excel boxes for other formulas to use it. However one of the combo boxes has almost 1500 items in the drop down and I'd like the user to be able to start typing a word in the combo box and get a list of suggestions to choose from based on the word entered for example if they type 'joh' in the combo box I want to show them a list of all the choices in the drop down that contains 'joh' so they can select the one they want. Now i can find the first 'joh' but it shows me like a list with what is near this 'joh', not specific all that contain 'joh'. Can i modify this code so can be used for what i want? Thank you and please help
-
To post as a guest, your comment is unpublished.The Combobox works fine when 1-MatchEntryComplete is selected ,when I changed the selection to 2-fmMatchEntryNone in the Combobox properties it did not work ,i.e It does not auto select as I start typing. Is there a fix for this?
-
To post as a guest, your comment is unpublished.
-
To post as a guest, your comment is unpublished.The code working but whenever I click on cell there the drop list auto prompt ,this make me unable to copy the contents and paste somewhere , how can I enable the copy and paste ?
-
To post as a guest, your comment is unpublished.
-
-
To post as a guest, your comment is unpublished.I try copy the whole cell of droplisting after all selection , but whenever I click on cell it auto show the listing , this has cost me unable to copy the cells and paste the contents somewhere , any solutions , pls help ?
-
To post as a guest, your comment is unpublished.
-
-
To post as a guest, your comment is unpublished.
-
To post as a guest, your comment is unpublished.
-
To post as a guest, your comment is unpublished.Hey guys, I'm having an issue where it doesn't let me type what I want to search for letter by letter. It just shows the whole word automatically and highlighted, and I start to type it moves it to the next closest word. is there anyway to not have it highlight the whole thing?
-
To post as a guest, your comment is unpublished.
-
To post as a guest, your comment is unpublished.
-
To post as a guest, your comment is unpublished.hi when i use the VBA code on a column that has dates it changes it to a number. can anyone help
-
To post as a guest, your comment is unpublished.Hi, Thaks for the code. Could I check if this formula can include an ignore blank function? This code took away my ignore blank function for my data validation. Please advise thanks
-
To post as a guest, your comment is unpublished.Hey, thanks for this! I have managed to get it to work, but like in Cartson's comment: I need to keep selections to the list. It populates ok, but if I enter a word not in the list, it still accepts it. The VBA code you replied with doesn't work unfortunately
Like in Data Validation/locked cell, can it create some error or not allow the typed entry not in the list?
Any help is much appreciated-
To post as a guest, your comment is unpublished.Hi Ben,
Sorry there are mistakes in the previous reply.
After inserting the combo box, open its Properties window, change the Name to TempCombo, and then select 2 - fmStyleDropDownList from the Style field, and finally apply the below code. From now on, it won't allow entering word not in the list.
Dim xRg As Range
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim xCombox As OLEObject
Dim xStr As String
Dim I As Long
Dim xWs As Worksheet
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 = Target
With xCombox
.Visible = True
.Left = Target.Left
.Top = Target.Top
.Width = Target.Width + 5
.Height = Target.Height + 5
.ListFillRange = xStr
.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)
Dim xSel As Range
On Error Resume Next
Select Case KeyCode
Case 13
xRg.Offset(0, 1).Select
End Select
End Sub-
To post as a guest, your comment is unpublished.
-
To post as a guest, your comment is unpublished.
-
To post as a guest, your comment is unpublished.Hello Crystal,
I have tried to do this... but it doesn't work... I have 4 lists 2 independent and the other two depend on others... It only works with the first list
-
-
-
To post as a guest, your comment is unpublished.Really great tutorial, thanks. Do you know how I can adapt this code to get it to work for merged cells? Thanks again.
-
To post as a guest, your comment is unpublished.Hi every one i noticed a few questions asking if there is a way to limit this to one column but i didn't notice any answers, was this ever figured out? i have multiple drop downs in my work sheet and they are all being affected by the macro where i only want column H to be affected. Any help with this would be greatly appreciated.
-
To post as a guest, your comment is unpublished.Hi Rob K,
The below VBA code can help you solve the problem, please have a try and thank you for your comment.
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
'Update by Extendoffice: 2019/8/14
Dim xCombox As OLEObject
Dim xStr As String
Dim xWs As Worksheet
Dim xArr
Dim xRgStr As String
Dim xRg As Range
xRgStr = "H:H"
Set xWs = Application.ActiveSheet
On Error Resume Next
Set xCombox = xWs.OLEObjects("TempCombo")
With xCombox
.ListFillRange = ""
.LinkedCell = ""
.Visible = False
End With
Set xRg = Intersect(Range(xRgStr), Target)
If xRg Is Nothing Then Exit Sub
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-
To post as a guest, your comment is unpublished.Hi,I am trying to pull that list data from another sheet but it does not work. below is my codePrivate Sub Worksheet_SelectionChange(ByVal Target As Range)
'Update by Extendoffice: 20190812
Dim xCombox As OLEObject
Dim xStr As String
Dim xWs As Worksheet
Dim xArr
Dim xRgStr As String
Dim xRg As Range
xRgStr = "MAINInput!$D:$D"
'MAINInput = sheet name where the list is available
Set xWs = Application.ActiveSheet
On Error Resume Next
Set xCombox = xWs.OLEObjects("cmbEmployee")
With xCombox
.ListFillRange = ""
.LinkedCell = ""
.Visible = False
End With
Set xRg = Intersect(Range(xRgStr), Target)
If xRg Is Nothing Then Exit Sub
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.cmbEmployee.List = xArr
End If
.LinkedCell = Target.Address
End With
xCombox.Activate
Me.cmbEmployee.DropDown
End If
End Sub
Private Sub cmbEmployee_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 -
To post as a guest, your comment is unpublished.Thank you for this fix! One quick question: I running this code across multiple worksheets (31 to be exact) but it is only affecting one. I have the code the same for each worksheet limiting the columns but it doesn't seem to be working on the other sheets. Thanks in advance!
-
-
To post as a guest, your comment is unpublished.Hi Rob K,
The below VBA code can help you solve the problem. Thank you for your comemnt.
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
'Update by Extendoffice: 20190812
Dim xCombox As OLEObject
Dim xStr As String
Dim xWs As Worksheet
Dim xArr
Dim xRgStr As String
Dim xRg As Range
xRgStr = "H:H" 'The range of cells containg drop-down lists you will make them autocomplete
Set xWs = Application.ActiveSheet
On Error Resume Next
Set xCombox = xWs.OLEObjects("TempCombo")
With xCombox
.ListFillRange = ""
.LinkedCell = ""
.Visible = False
End With
Set xRg = Intersect(Range(xRgStr), Target)
If xRg Is Nothing Then Exit Sub
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
-
-
To post as a guest, your comment is unpublished.When I paste the VBA code, do I need to change the Worksheet code editor to the Worksheet and Before Double Click? I changed those 2 fields and it populated codes into the code editor screen. So where do I paste the VBA code? after those? Before those? do I delete those 2 codes that autofill and then paste? I tried that but then the Worksheet changed back to General and Declarations and the code doesn't make my cells autofill. What am I doing wrong???
-
To post as a guest, your comment is unpublished.How can i use same list for another combo box, do i need to write same code for another combo box, as i require 10 combo box
-
To post as a guest, your comment is unpublished.
-
To post as a guest, your comment is unpublished.
-
To post as a guest, your comment is unpublished.How can the code be modified such that pressing SHIFT + TAB moves the cursor left in the row?
-
To post as a guest, your comment is unpublished.Hi Anthony,
Sorry can't help you with that. Thank you for your comment.-
To post as a guest, your comment is unpublished.
-
-
-
To post as a guest, your comment is unpublished.But what if i have dynamic list ? How can i provide the input to the combobox and refresh everytime the data is been added?
-
To post as a guest, your comment is unpublished.
-
To post as a guest, your comment is unpublished.
-
-
To post as a guest, your comment is unpublished.Anyone looking for a simple dropdown input form in excell based on a list; i used Data.. "Data Validation" and then choose Allow: "List" and pointed the source at the list.
This does not do the auto complete but does avoid any macros or dev and just uses native simple Excel features. -
To post as a guest, your comment is unpublished.