How to Add an Input Message in Data Validation

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.


image 1


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:-

  • Open the VBE page to press the key Alt+F11.
  • Insert the module to write the code.
  • Write the below mentioned 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


Code Explanation:-

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.


image 2


To run the code press the key F5 on your keyboard

  • Drop down list will be created for the countries.
  • And also, cell will be filled with color.
  • And also, whenever we will enter the new country name in the range, drop down list will pick the country name automatically.
  • Message will appear in the selected cell in the range of A1:A10.


image 3


In this way, we can add an input message in data validation through VBA in Microsoft Excel.


image 48


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



  1. freebitcoin ????????? ??? ?????

    freebitcoin ?????????
    freebitcoin ??????
    ??? ?????????? ???????

    freebitcoin ??????

Leave a Reply

Your email address will not be published. Required fields are marked *

Terms and Conditions of use

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.