See my 2 inline comments...
2) Your "If IsNumeric(num) And num = Int(num) Then" statement will fail if
text is entered into one of the target cells (the Int function call will
fail). You can use this statement instead...
If not num Like "*[!0-9]*" Then
which makes sure that a non-digit is not located anywhere within the
contents of the num variable (it handles both the IsNumeric and "is
integer"
issues with one test).
I noted that also, and was going to post a correction this morning. Yours
is
succinct, but fails on ERROR values with a type mismatch error.
There is that damned behind-the-scenes
VB type coercion screwing around with
things again. There is a simple fix for my Like operator statement that will
handle errors as well. This If..Then statement should work fine...
If Not CStr(num) Like "*[!0-9]*" Then
And here is a modification that shortens the routing by eliminating the
two
Select Case blocks (but which is just a *tad* more obfuscated<g)...
I find shortened routines to be quite useful sometimes, but I prefer
clarity in
this instance.
Yeah... that is why I made the obfuscation comment and added the <g tag to
it.
--
Rick (MVP - Excel)