checking the format of a string in a cell
Hello, Corbin!
The best way to simplify input validation is to isolate the components and
examine them separately.
For example, you could use the Split function with each cell value to return a
zero-based, one-dimensional array of substrings using the comma as the
delimiter. This would give you an array like the one below.
00B123445
S/N 04A12345
03C345566
01G3456
9H23456
Your first test would be to see if the array has too few or too many elements.
The UBound function should return a value of 4 for a 5-element array like this
one.
Then you could loop through the array and apply tests for the format you
require in each component -- maybe even creating a separate subroutine for each
array element.
Earlier versions of Excel do not support the Split function, so if you have,
say, Excel 97, you'll have to create your own version of it.
Data validation is always a lot of work. I hope this helps.
Regards,
Wes
|