+ Reply to Thread
Results 1 to 11 of 11

Userform question

  1. #1
    Registered User
    Join Date
    02-27-2013
    Location
    Florida
    MS-Off Ver
    Excel 2007
    Posts
    14

    Userform question

    I have a user form with a few text boxes.

    Can someone please give an example of what's the best way for the user forms text boxes hold user inputted values in them and for those values to be referenced by other macros.

    I know that once a user form is unloaded, all of the data in it goes away. So I would need a command button in it to simply hide the user form.
    Is there a way to prevent a user form from being closed by pressing the x at the top right?

    I have many rows for which I intend to create such a user form. And the values from the text boxes will be used as values in other code.

    Does anyone know of ways to go about this?

    Than you

  2. #2
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Userform question

    hi

    you should store all your userform information onto a worksheet as you make changes.

    That way you will only lose information if you close the workbook without saving it.

    Then again your code could force the userform to be saved. So even then you would be safe.

    You could sun a subroutine each time anything is changed on the userform to save the data.

    I will dig out a some sample code for you. BRB

  3. #3
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Userform question

    Darn the system crashed on me after I wrote a lot of code for you.

    I will try again.

  4. #4
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Userform question

    Ok I will create this in stages for you.

    When you activate the userform, declare a public array to store your textbox data.

    Also Dimension the array.



    Please Login or Register  to view this content.

  5. #5
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Userform question

    Please Login or Register  to view this content.
    using "Saver(6) passes the textbox number to the saver routine, so you only need to save the textbox that has been changed.

    using "saver2" doesn't pass the text box no to Saver2 and means you have to save all textboxes whenever one is changed.



    Please Login or Register  to view this content.

  6. #6
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Userform question

    Ok

    That should give you the germ of an idea.

    Good Luck.

  7. #7
    Registered User
    Join Date
    02-27-2013
    Location
    Florida
    MS-Off Ver
    Excel 2007
    Posts
    14

    Re: Userform question

    Thank you, I will play with the code

  8. #8
    Registered User
    Join Date
    02-27-2013
    Location
    Florida
    MS-Off Ver
    Excel 2007
    Posts
    14

    Re: Userform question

    So suppose I have a user form with a few numbers in it. And I want to use the value from userform3.textbox5 as a value in another piece of code.
    What would the correct syntax be?

  9. #9
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Userform question

    The array will store numbers as well as text

    you could use
    Please Login or Register  to view this content.
    to check that the contents of a specific textbox is numerical, if not do something like clear it or delete all the text in that box.

    The subroutine below is something I wrote to ensure that the contents of a text box are numerical. The N is the textbox number.

    Please Login or Register  to view this content.

  10. #10
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Userform question

    The Numeric function was created to accept either a number or a series of numbers separated by "," or "/".

  11. #11
    Registered User
    Join Date
    02-27-2013
    Location
    Florida
    MS-Off Ver
    Excel 2007
    Posts
    14

    Re: Userform question

    Thanks man!

+ 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