DataValidation Element (Microsoft Excel)

Contains the data validation criteria, input message, and error message elements of the specified range.

Contained In

XML

Subelements

CellRangeList, ComboHide, ErrorHide, ErrorMessage, ErrorStyle, ErrorTitle, IMEMode, InputHide, InputMessage, InputTitle, Max, Min, Qualifier, Range, Type, UseBlank, Value

Remarks

You must specify the Min subelement, the Max subelement, both the Min and Max subelements, or the Value subelement and an optional ComboHide subelement.

The Range element is required, but all other subelements are optional. CellRangeList can be specified only when the data validation is performed against a list.

Examples

This example prompts the user to enter a part number value that is validated against a list of available part numbers in the range Z1:Z6. Any blank cells in this range are used in the validation. A drop-down arrow and combo box are not displayed in the cell, and the Input Method Editor is turned off. If the data is valid, the part number is stored in cell B4, but if the data is not in the list, an error message is displayed.


 <x:DataValidation>
  <x:Range>B4</x:Range>
  <x:Type>List</x:Type>
  <x:UseBlank/>
  <x:Value>$Z$1:$Z$6</x:Value>
  <x:ComboHide/>
  <x:IMEMode>2</x:IMEMode>
  <x:InputMessage>Enter part number</x:InputMessage>
  <x:InputTitle>Check Inventory</x:InputTitle>
  <x:ErrorMessage>Part not found in inventory</x:ErrorMessage>
  <x:ErrorTitle>Not Found</x:ErrorTitle>
  <x:ErrorStyle>Info</x:ErrorStyle>
 </x:DataValidation>

This example requires the user to enter a decimal number from 5 to 15, which is stored in cell A4 if it is within this range. Neither the input message nor the error message are displayed.


 <x:DataValidation>
  <x:Range>A4</x:Range>
  <x:Type>Decimal</x:Type>
  <x:Qualifier>Between</x:Qualifier>
  <x:Min>5</x:Min>
  <x:Max>15</x:Max>
  <x:InputHide/>
  <x:ErrorHide/>
 </x:DataValidation>

This example validates an input value against a list of integer numbers from 1 to 4. The number is stored in cell B2 if it is within this range.


 <x:DataValidation>
  <x:Range>B2</x:Range>
  <x:Type>List</x:Type>
  <x:CellRangeList/>
  <x:Value>&quot;1,2,3,4&quot;</x:Value>
 </x:DataValidation>