View Single Post
  #9   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Harlan Grove[_2_] Harlan Grove[_2_] is offline
external usenet poster
 
Posts: 1,231
Default A validation rule on Alpha and Numeric characters

"Rick Rothstein \(MVP - VB\)" wrote...
....
If, according to the OP, the entry is incorrect and not acceptable,
why would it matter that it is permanently erased or undone?


Because the PREVIOUS entry is likely to have been valid, and it may be
preferable to preserve an outdated valid entry than to change the
entry to "" (which isn't the same as clearing the cells contents -
that involves setting the FORMULA property to "" - setting the VALUE
property to "" makes the cell nonblank containing a zero-length
string).

I also just noticed that you made a common mistake: you failed to set
Application.EnableEvents to FALSE before and TRUE after modifying
Target, which would otherwise cause the event handler to trigger
itself. You didn't test your code?

Also, Target COULD be a multiple cell range, which would
make it an even worse idea to set all cells to "".


I just tried the macro against a larger selection and multiple
individual selections and the only cell that was erased was the
active cell. I'm using Excel 2003 if that makes a difference. Does
this code work differently in Excel 2003 than other (earlier?)
versions?

....

You have to ENTER multiple cells at once, e.g., array formulas or
multiple cell entries using [Ctrl]+[Enter] or PASTING into a multiple
cell range. Maybe the first is unlikely since users wouldn't be
entering array formulas, the second unlikely because users wouldn't
know about it, but the third is quite possible, and you should learn
to accommodate it.

Event handlers only work when macros are enabled, and it's simple
for users to disable macros. Data validation ALWAYS works.


That is a valid point and I can't argue with it at all. I would
note, though, that company policy might make disabling macros on
company spreadsheets a thing not to do, . . .


And some companies have policies of no macros AT ALL, making event
handlers of purely academic interest.

Anyway, if you're going to propose event handlers, you should address
means of discouraging users from disabling macros.