In this article, we will learn how to add an input message in data validation while entering the specific entries in the cell, using VBA in Microsoft Excel.
Data Validation is the tool that is used to restrict the entry in a range or data so that we can define that which type of data should be entered in the sheet.
Let’s take an example and understand:-
We have countries’ name in D column, and in cell A1, we want to create a drop down filter for countries’ name.
We want to highlight the cell A1 and make the drop down list to countries’ name and put the message to let the users know which entries need to be entered in the range.
Follow below given steps and code:-
Sub DropDownFilter() Dim lastrow As Long lastrow = Worksheets("sheet1").Cells(Rows.Count, "D").End(xlUp).Row With Range("A1:A10").Validation .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:=xlBetween, Formula1:="=$D$2:$D" & lastrow .IgnoreBlank = True .InCellDropdown = True .InputTitle = "Message" .InputMessage = "Enter only countries name" Range("A1:A10").Interior.ColorIndex = 37 End With End Sub
First we had defined all the variables, then we had created the range which would help to create the dynamic drop down filter. Similarly, we had defined the input title and Input message. And then we had defined the destination where we want to create the drop down list and then we would fill the cell with color.
To run the code press the key F5 on your keyboard
In this way, we can add an input message in data validation through VBA in Microsoft Excel.
If you liked our blogs, share it with your friends on Facebook. And also you can follow us on Twitter and Facebook.
We would love to hear from you, do let us know how we can improve, complement or innovate our work and make it better for you. Write us at firstname.lastname@example.org
The applications/code on this site are distributed as is and without warranties or liability. In no event shall the owner of the copyrights, or the authors of the applications/code be liable for any loss of profit, any problems or any damage resulting from the use or evaluation of the applications/code.
freebitcoin ????????? ??? ?????
??? ?????????? ???????