+ Reply to Thread
Results 1 to 5 of 5

simple 'if statement' problem

  1. #1
    Forum Contributor
    Join Date
    09-13-2012
    Location
    Midwest
    MS-Off Ver
    Excel 365
    Posts
    124

    simple 'if statement' problem

    Hello All,

    I'm having problem with the code below. If I use the <> operator, then it does not show the msgbox and enters the data into the database when it shouldn't, but if I use the > operator, then I get a mismatch error message. I just want my msgbox to show when textbox5 does not equal zero and all the other textboxes have no value in them. Ideally, if textbox5 have a number greater than zero, then at least one of the other textboxes should have a number in it.

    Please Login or Register  to view this content.
    Thank you!

  2. #2
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: simple 'if statement' problem

    Maybe:

    Please Login or Register  to view this content.
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  3. #3
    Forum Contributor
    Join Date
    09-13-2012
    Location
    Midwest
    MS-Off Ver
    Excel 365
    Posts
    124

    Re: simple 'if statement' problem

    Sorry, I should've specified that this is in a userform and runs when clicking the commandbutton.

  4. #4
    Forum Contributor
    Join Date
    09-13-2012
    Location
    Midwest
    MS-Off Ver
    Excel 365
    Posts
    124

    Re: simple 'if statement' problem

    I fixed it. I made the first condition: if textbox5.Text <> "0"
    Then added an userform initialize event to make textbox5 = 0 on launch.
    Seems to fix it just fine.

    Thanks anyhow!

  5. #5
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: simple 'if statement' problem

    Your welcome! It could have been:
    Please Login or Register  to view this content.
    rather than
    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1