+ Reply to Thread
Results 1 to 9 of 9

Clearing userform contents after saving to worksheet

  1. #1
    Registered User
    Join Date
    11-30-2012
    Location
    North Carolina
    MS-Off Ver
    Office 365
    Posts
    60

    Clearing userform contents after saving to worksheet

    I have a vba user form. The form has multiple combo boxes and text boxes. The first combo box is populated with the form's initialization. The second and third combo boxes are dependent; choices in the second combo box are based on Select case statements based on the first combox selection. The third combo box is similarly populated based on the second combo box selection. Based pm the selection of the third combo box selection, i have a vba lookup to populate several text boxes on the form.

    Please Login or Register  to view this content.
    Everything works fine until i save the form. After saving, i want to clear the form for re-entry. I have a cmdClear button with the following code:

    Please Login or Register  to view this content.
    This code clears nothing. Any suggestions would be useful.

  2. #2
    Registered User
    Join Date
    07-07-2020
    Location
    San Diego
    MS-Off Ver
    2010
    Posts
    7

    Re: Clearing userform contents after saving to worksheet

    upon the save button click at the very end you need to also call the cmdClear sub,

    a potential issue that i see in your clearing macro is your not technically clearing the textbox or combo box, your just placing a blank space in there, instead of "ctrl.Text = "" " try using the ".Clear" command. which will reset the object instead of just retyping a blank.

  3. #3
    Registered User
    Join Date
    11-30-2012
    Location
    North Carolina
    MS-Off Ver
    Office 365
    Posts
    60

    Re: Clearing userform contents after saving to worksheet

    Sorry, no change. Thank you for your suggestion.

  4. #4
    Registered User
    Join Date
    07-07-2020
    Location
    San Diego
    MS-Off Ver
    2010
    Posts
    7

    Re: Clearing userform contents after saving to worksheet

    can you attach the whole file?

  5. #5
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,635

    Re: Clearing userform contents after saving to worksheet

    through your entire code you use ctrl

    except here
    Please Login or Register  to view this content.
    where you use ctl. So it's just a case of a typo.
    Avoid using Select, Selection and Activate in your code. Use With ... End With instead.
    You can show your appreciation for those that have helped you by clicking the * at the bottom left of any of their posts.

  6. #6
    Registered User
    Join Date
    11-30-2012
    Location
    North Carolina
    MS-Off Ver
    Office 365
    Posts
    60

    Re: Clearing userform contents after saving to worksheet

    Thank you, pointing out the typo, embarrassing as it is that i did not catch that, helps. I can now clear the combo boxes. But i do appear to have a logic problem. The vlookup function is triggered by the change event in combo box3, so when i clear that combo box, it is generating an error in efforts to clear the textboxes populated by the vlookup results.

    Any suggestions on how i can structure an option to the Private Sub ComboBox3_Change()?

  7. #7
    Valued Forum Contributor
    Join Date
    04-01-2015
    Location
    The Netherlands
    MS-Off Ver
    2003/2007/2010/2016/office 365
    Posts
    624

    Re: Clearing userform contents after saving to worksheet

    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    11-30-2012
    Location
    North Carolina
    MS-Off Ver
    Office 365
    Posts
    60

    Re: Clearing userform contents after saving to worksheet

    Excellent. I appreciate the help; problem is not solve.

  9. #9
    Registered User
    Join Date
    11-30-2012
    Location
    North Carolina
    MS-Off Ver
    Office 365
    Posts
    60

    Re: Clearing userform contents after saving to worksheet

    The problem is NOW solved; typos abound. Thank you all.

+ 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. Clearing contents of multiple TextBox and ListBox on UserForm
    By Xceller in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 03-13-2020, 03:10 PM
  2. Replies: 3
    Last Post: 05-07-2019, 06:54 PM
  3. [SOLVED] Saving value on worksheet from userform combobox
    By Stvone in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-23-2017, 05:54 PM
  4. [SOLVED] Clearing contents in another worksheet merged rang based on a change to a validation list.
    By skarrletter in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-22-2015, 01:00 PM
  5. Saving userform data to another worksheet
    By stevo365 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-14-2008, 09:08 AM
  6. Saving contents of a Userform to another file.
    By ASU in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-01-2006, 11:25 AM
  7. saving and reloading the contents of a userform
    By bennyob in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-07-2005, 11:20 PM

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