+ Reply to Thread
Results 1 to 7 of 7

User Form Basics - Populating Text Boxes

  1. #1
    Registered User
    Join Date
    07-06-2009
    Location
    NH, USA
    MS-Off Ver
    2010 & 2013
    Posts
    38

    Question User Form Basics - Populating Text Boxes

    If anybody has a link to a good tutorial on user forms, it would be greatly appreciated. Failing that...

    I am trying to create a user form to edit some named ranges. The VBA user form designer is basically the same as Borland Delphi, so building the form itself was easy. What I can't figure out is how to populate the user form with the data from the spreadsheet.

    I have a number of text boxes on the form with names like txtTier1Slots, txtTier1Ceiling, txtTier1Floor, etc up to 4.

    I have a defined name that corresponds with each item, Tier1Slots, Tier1Ceiling, Tier1Floor, and so on. I'm using defined names because they're referenced in Conditional Formatting on one of the worksheets in my project. They don't exist as actual cells, just name references.

    I want to get the form populated with those values. I've tried about twenty variations of the following code, using ThisWorkbook, Workbooks, Cells, Range, Name, and just about every cell reference method I can think of. I've so many different error messages, my head is spinning.

    Please Login or Register  to view this content.
    Any thoughts?
    Last edited by T.J. Lanza; 09-23-2009 at 02:58 PM. Reason: Problem solved, though I still have how/why questions.

  2. #2
    Forum Expert davegugg's Avatar
    Join Date
    12-18-2008
    Location
    WI, US
    MS-Off Ver
    2010
    Posts
    1,884

    Re: User Form Basics - Populating Text Boxes

    Please Login or Register  to view this content.
    Is your code running too slowly?
    Does your workbook or database have a bunch of duplicate pieces of data?
    Have a look at this article to learn the best ways to set up your projects.
    It will save both time and effort in the long run!


    Dave

  3. #3
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: User Form Basics - Populating Text Boxes

    The names mus refer o a range or cell. Can you attach a small example workbook?
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  4. #4
    Registered User
    Join Date
    07-06-2009
    Location
    NH, USA
    MS-Off Ver
    2010 & 2013
    Posts
    38

    Unhappy Re: User Form Basics - Populating Text Boxes

    Quote Originally Posted by royUK View Post
    The names mus refer o a range or cell. Can you attach a small example workbook?
    The names are defined directly in the Name Manager. The intent of this user form is to allow them to be changed by people who don't know how Name Manager works and shouldn't be mucking around with it.

    Anyway, I've attached a stripped down workbook. It's got the form, the defined names, and a single worksheet with a button to activate the form. None of the controls on the form do anything.

    I'm trying to find the right syntax to get the text boxes populated. I don't know the combination of objects, methods, and properties to get anything into a user form. Microsoft's own VBA language reference is less than helpful. My feeling is that it's some sort of scope-related issue...
    Attached Files Attached Files

  5. #5
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: User Form Basics - Populating Text Boxes

    The first name you mentioned does not exist in the workbook, see list that I have created.

    I have put some code in to get you started
    Attached Files Attached Files

  6. #6
    Registered User
    Join Date
    07-06-2009
    Location
    NH, USA
    MS-Off Ver
    2010 & 2013
    Posts
    38

    Re: User Form Basics - Populating Text Boxes

    Quote Originally Posted by royUK View Post
    The first name you mentioned does not exist in the workbook, see list that I have created.

    I have put some code in to get you started
    Woops! The form objects used "txtTier_Slots", but the Defined Names used "intTier_Size". Sorry 'bout that. I corrected them on my end, and it works like a charm.

    Now, another question... What does that square-bracket notation around the Defined Names mean? I don't think I've ever seen that before.

  7. #7
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: User Form Basics - Populating Text Boxes

    The square brackets are short hand for Evaluate, it checks the Name's value

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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