Results 1 to 8 of 8
  1. #1
    Star Lounger
    Join Date
    Apr 2001
    Location
    SOUTH AFRICA
    Posts
    74
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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. #2
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Weert, Limburg, Netherlands
    Posts
    4,812
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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
    Jan Karel Pieterse
    Microsoft Excel MVP, WMVP
    www.jkp-ads.com
    Professional Office Developers Association

  3. #3
    Star Lounger
    Join Date
    Apr 2001
    Location
    SOUTH AFRICA
    Posts
    74
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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. #4
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Weert, Limburg, Netherlands
    Posts
    4,812
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: If statement (97)

    Yes, great to see you discovered my deliberate mistake <vbg>
    Jan Karel Pieterse
    Microsoft Excel MVP, WMVP
    www.jkp-ads.com
    Professional Office Developers Association

  5. #5
    Star Lounger
    Join Date
    Jun 2001
    Posts
    91
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: If statement (97)

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

  6. #6
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Weert, Limburg, Netherlands
    Posts
    4,812
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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!)
    Jan Karel Pieterse
    Microsoft Excel MVP, WMVP
    www.jkp-ads.com
    Professional Office Developers Association

  7. #7
    Lounger
    Join Date
    Aug 2001
    Location
    Shropshire, UK
    Posts
    43
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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. #8
    Star Lounger
    Join Date
    Jun 2001
    Posts
    91
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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
  •