ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How do I require data entry in a combo box in Excel? (https://www.excelbanter.com/excel-programming/420036-how-do-i-require-data-entry-combo-box-excel.html)

noviceql

How do I require data entry in a combo box in Excel?
 
I'd like to require a selection from a combo box in a form in Excel before
the form is saved. (Also with a msg box)

What's the best way to do this?

Thanks

royUK[_39_]

How do I require data entry in a combo box in Excel?
 

Place this code in your save button, make sure the control names match
yours


Code:
--------------------
Option Explicit

Private Sub CommandButton1_Click()
With Me
If .ComboBox1.ListIndex - 0 Then
MsgBox "You must select from the dropdown list", vbCritical, "Input required"
.ComboBox1.SetFocus
Exit Sub
Else: 'your save code here
End If
End With
End Sub
--------------------


--
royUK

Hope that helps, RoyUK
For tips & examples visit my 'web site
' (http://www.excel-it.com)
------------------------------------------------------------------------
royUK's Profile: http://www.thecodecage.com/forumz/member.php?userid=15
View this thread: http://www.thecodecage.com/forumz/sh...ad.php?t=29624



All times are GMT +1. The time now is 03:59 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com