# Thread: If statement (97)

1. ## If statement (97)

Hi there,

How do I code the following:

if intmonth <> 1 or 2 or 3 ....12 then
exit sub

The inputbox must not contain blanks, alpha or numeric besides 1-12

Please help again.

Thanks a lot

2. ## Re: If statement (97)

If I assume intmonth is declared as integer, entering anything else into it than integers would give errors. so assuming that:

If intmonth<1 and intmonth>12 then exit sub

3. ## Re: If statement (97)

Hi Jan Karel,

I suppose you meant OR and not AND : If intmonth<1 and intmonth>12 then exit sub.

But thanks a lot again to you, it works 100%.

4. ## Re: If statement (97)

Yes, great to see you discovered my deliberate mistake <vbg>

5. ## Re: If statement (97)

No no no! How can something be BOTH <1 and >12?? OR was right,not AND.

6. ## Re: If statement (97)

Hi Bob,

yes, yes, yes, <vbg>. I did have AND mistakenly. But that has been spotted as you can see in the posts.
Nice to see you around here. Reminds me of the compuserve Excel forum days (it is still there, merged with the other office fora now and alive and kicking!)

7. ## Re: If statement (97)

Bit of lateral thinking...
how about half past 12!!! That's greater than 12 AND less than 1(pm). <img src=/S/grin.gif border=0 alt=grin width=15 height=15>

8. ## Re: If statement (97)

We weren't talking about time, but about numbers. In either case, NOTHING will pass a test of being both <1 and >12 in VBA, not even 12:30.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•