+ Reply to Thread
Results 1 to 7 of 7

HELP: If (A And B And C...) Then Else... Always doing Else

  1. #1
    Registered User
    Join Date
    04-22-2013
    Location
    Baton Rouge, LA
    MS-Off Ver
    Excel 2010
    Posts
    20

    HELP: If (A And B And C...) Then Else... Always doing Else

    Hey Guys,

    I am using textboxes in a userform to write data in excel.
    The last cell is set up with prewritten text if values are entered in certain textboxes of the user form.

    I want the last cell to be blank if nothing is entered in any of the 5 textboxes. Yet if something is entered in any one of the 5 textboxes then I want the last cell to be filled with data.

    My If/Then/Else code is ignoring my If/Then and executing the Else no matter what.

    Here is the code

    Please Login or Register  to view this content.
    Please Advise

  2. #2
    Valued Forum Contributor
    Join Date
    03-29-2013
    Location
    United Kingdom
    MS-Off Ver
    Office/Excel 2013
    Posts
    1,749

    Re: HELP: If (A And B And C...) Then Else... Always doing Else

    It'll only execute the IF when ALL the named textboxes are empty. For whatever reason this isn't ever happening.
    Elegant Simplicity............. Not Always

  3. #3
    Registered User
    Join Date
    04-22-2013
    Location
    Baton Rouge, LA
    MS-Off Ver
    Excel 2010
    Posts
    20

    Re: HELP: If (A And B And C...) Then Else... Always doing Else

    Right. That is what I want it to do.
    But I could run it without ever putting my cursor in any of those textboxes and it will still do my else.
    It may be something I am overlooking in the code. Even if I put an ' on the last 4 conditions of the IF and try to run it with just the 1st condition, it still does the ELSE.

  4. #4
    Registered User
    Join Date
    04-22-2013
    Location
    Baton Rouge, LA
    MS-Off Ver
    Excel 2010
    Posts
    20

    Re: HELP: If (A And B And C...) Then Else... Always doing Else

    I do not have a UserForm_Initialize setup. Maybe I will try that so that my textbox.values="" at the beginning.

  5. #5
    Valued Forum Contributor
    Join Date
    03-29-2013
    Location
    United Kingdom
    MS-Off Ver
    Office/Excel 2013
    Posts
    1,749

    Re: HELP: If (A And B And C...) Then Else... Always doing Else

    Yeah ... Might be worth trying as a test...

  6. #6
    Registered User
    Join Date
    04-22-2013
    Location
    Baton Rouge, LA
    MS-Off Ver
    Excel 2010
    Posts
    20

    Re: HELP: If (A And B And C...) Then Else... Always doing Else

    OK, so I am about to incorporate a personal rule: "Try troubleshooting the issues for 48hrs before getting ExcelForum involved."

    As I ran my code just now, I noticed that I had this "problem code" in my NextButton_Click. Yet I was testing the code by clicking my FinishButton, which I had not input this If/Then/Else condition into that sub yet. I knew it had to be something simple like that because the condition was written correctly. Anyway, it works now.

    Sorry for the trouble and thanks for responding AndyLitch.

    Until next time....

  7. #7
    Valued Forum Contributor
    Join Date
    03-29-2013
    Location
    United Kingdom
    MS-Off Ver
    Office/Excel 2013
    Posts
    1,749

    Re: HELP: If (A And B And C...) Then Else... Always doing Else

    Been there, done that ....... Good luck

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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