+ Reply to Thread
Results 1 to 10 of 10

open excel and ensure userform and worksheet are clear

  1. #1
    Registered User
    Join Date
    11-04-2013
    Location
    Leeds
    MS-Off Ver
    Excel 2010
    Posts
    62

    open excel and ensure userform and worksheet are clear

    Hello,

    I have a userform and data from the textboxes are transferred to the worksheet after the user has filled out the form. I was wondering, is there a code I can use to ensure that when the user re opens the form/excel, that all text boxes from the userforms (there are 4 userforms) as well as the text from the spreadsheet are cleared? Many Thanks

  2. #2
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: open excel and ensure userform and worksheet are clear

    Please Login or Register  to view this content.
    Try putting this in each userform code module
    Thanks,
    Solus


    Please remember the following:

    1. Use [code] code tags [/code]. It keeps posts clean, easy-to-read, and maintains VBA formatting.
    Highlight the code in your post and press the # button in the toolbar.
    2. Show appreciation to those who have helped you by clicking below their posts.
    3. If you are happy with a solution to your problem, mark the thread as [SOLVED] using the tools at the top.

    "Slow is smooth, smooth is fast."

  3. #3
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,646

    Re: open excel and ensure userform and worksheet are clear

    If you unload the userform(s) then when you open them again they should be blank, provided you haven't set any default values at design time.
    If posting code please use code tags, see here.

  4. #4
    Registered User
    Join Date
    11-04-2013
    Location
    Leeds
    MS-Off Ver
    Excel 2010
    Posts
    62

    Re: open excel and ensure userform and worksheet are clear

    Thankyou guys The code you have given me Solus works so thankyou very much. Although I didnt mention, on the first 2 userforms there is a text box at the top of each with set text in which should always be there and never change. I had disabled the box so the user cannot edit it but this code deletes the text thats in it. Is there any way I could keep the code but put an exception on for these 2 textboxes?

    Thankyou

  5. #5
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,646

    Re: open excel and ensure userform and worksheet are clear

    You could use a label instead of a textbox.

  6. #6
    Registered User
    Join Date
    11-04-2013
    Location
    Leeds
    MS-Off Ver
    Excel 2010
    Posts
    62

    Re: open excel and ensure userform and worksheet are clear

    Thats a good idea. Although Ive just tried it and at the bottom of the userform i have a command button which concatenates all of the text from that sheet into a different textbox. When I have tried to copy the text from the label is doesnt seem to work......

  7. #7
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,646

    Re: open excel and ensure userform and worksheet are clear

    Not work in what way?

  8. #8
    Registered User
    Join Date
    11-04-2013
    Location
    Leeds
    MS-Off Ver
    Excel 2010
    Posts
    62

    Re: open excel and ensure userform and worksheet are clear

    It just says 'method or data member not found'. This is the code I have put in. Seems strange not to pick up the text from the label....

    Me.TextBox6.Text = Label7.Text & TextBox2.Text & ComboBox1.Text & ComboBox2.Text

  9. #9
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,646

    Re: open excel and ensure userform and worksheet are clear

    Try Label7.Caption.

  10. #10
    Registered User
    Join Date
    11-04-2013
    Location
    Leeds
    MS-Off Ver
    Excel 2010
    Posts
    62

    Re: open excel and ensure userform and worksheet are clear

    Thats amazing it worked, thankyou Norie!!

+ 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. [SOLVED] Unable to add data via userform when another worksheet is open
    By Janto724 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 07-25-2013, 09:11 AM
  2. [SOLVED] Excel vba userform- cancel button needs clear all fields
    By PANTECH in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-26-2013, 02:51 PM
  3. [SOLVED] clear userform does not clear all boxes
    By cfinch100 in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 01-23-2013, 11:43 AM
  4. [SOLVED] Open a userform on worksheet double click
    By hchurch in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-29-2010, 11:52 AM
  5. Ensure userform fields are complete
    By pkling in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 04-23-2010, 06:48 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