+ Reply to Thread
Results 1 to 6 of 6

Exception to If/Then statement

  1. #1
    Registered User
    Join Date
    12-02-2014
    Location
    Washington DC
    MS-Off Ver
    Office 2013
    Posts
    24

    Exception to If/Then statement

    I have created a userform with many TextBoxes and ComboBoxes. To clear them all at once after inputs are entered, I have used the following code:

    Please Login or Register  to view this content.
    TextBox1, however, contains the day's date and should not be cleared. Is there a way to specify that all boxes are cleared EXCEPT TextBox1?

  2. #2
    Forum Expert skywriter's Avatar
    Join Date
    06-09-2014
    Location
    USA
    MS-Off Ver
    2016
    Posts
    2,760

    Re: Exception to If/Then statement

    Try this.

    Please Login or Register  to view this content.
    Click the * Add Reputation button in the lower left hand corner of this post to say thanks.

    Don't forget to mark this thread SOLVED by going to the "Thread Tools" drop down list above your first post and choosing solved.

  3. #3
    Registered User
    Join Date
    12-02-2014
    Location
    Washington DC
    MS-Off Ver
    Office 2013
    Posts
    24

    Re: Exception to If/Then statement

    Thanks! I think a line fell out of your version, but after reinserting it, it worked great! Thank you!!
    Final version:
    Please Login or Register  to view this content.

  4. #4
    Forum Expert skywriter's Avatar
    Join Date
    06-09-2014
    Location
    USA
    MS-Off Ver
    2016
    Posts
    2,760

    Re: Exception to If/Then statement

    If you mean the for each part, I probably just didn't copy it from your original post. If you think about it where you moved the line you will run that line of code every time, which isn't necessary. In my version it only runs if the control type has been verified to be a text box. Make sense?

  5. #5
    Registered User
    Join Date
    12-02-2014
    Location
    Washington DC
    MS-Off Ver
    Office 2013
    Posts
    24

    Re: Exception to If/Then statement

    Yes, it does make sense. I did your way first, actually, but got an error message saying that there was an End If without an If. That didn't make sense to me, but I saw that the one line wasn't there and I tried putting it back in, which worked.

  6. #6
    Forum Expert skywriter's Avatar
    Join Date
    06-09-2014
    Location
    USA
    MS-Off Ver
    2016
    Posts
    2,760

    Re: Exception to If/Then statement

    Here's another possibility. It works, I tested it.

    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)

Similar Threads

  1. exception of zero
    By stefrgv in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 08-24-2013, 11:56 AM
  2. [SOLVED] Adding an exception statement
    By Biased Historian in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-02-2012, 01:40 PM
  3. COM exception
    By grasyl in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-25-2011, 04:41 AM
  4. Exception deleting
    By cj21 in forum Excel General
    Replies: 5
    Last Post: 01-26-2006, 12:05 PM
  5. HyperLink Exception
    By Edi in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-06-2005, 04:05 AM

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