+ Reply to Thread
Results 1 to 6 of 6

Userform possibility question

  1. #1
    Registered User
    Join Date
    06-19-2011
    Location
    houston, texas
    MS-Off Ver
    Excel 2007
    Posts
    3

    Userform possibility question

    I want to write a VBA excel code that will allow the user to double click on a line and have a userform pop up. The user for will customize itself based on the information in that line. It will see I clicked on line 7 and it will add the label for line 7. The problem is that I need it to go deeper. I want to use the userform to adjust some numbers at a more granular level than the line that they clicked on is. The form will have to take corresponding information and add a variable number of labels and text boxes and spinboxes (up to 20). Each line will be different. My question is: Is it possible to add a variable number of labels, text boxes and spin boxes and position them at run time?

  2. #2
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,167

    Re: Userform possibility question

    Hi benfinn,

    Most things are possible with VBA with enough study and effort. In your case, I'd put all labels and text boxes and controls on your userform and then either make them visible or not based on the row you double click on.

    Hope this makes your problem easier.
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  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: Userform possibility question

    Vague question, the answer would be yes.
    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
    06-19-2011
    Location
    houston, texas
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: Userform possibility question

    Sorry for being too vague RoyUK.

    MarvinP - Thank you so much that does make my life easier. The aesthetics might be off a bit since I will need to make so many invisible (There might be large empty spaces to account for the hidden labels and boxes) but it should be an easier solution to someone of my skillset.

    Do you think you could give me a small example code of how to alter the properties of the userform at runtime? I'll run a loop to count the number of labels needed to be unhid but I dont know too well how to alter userforms and I am having trouble finding example code.

  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: Userform possibility question

    You still aren't giving enough information for what you want, what determines the number of rows & labels required? What do you mean by granukar?

    If you explain the problem properly there is probably a simpler solution

  6. #6
    Registered User
    Join Date
    06-19-2011
    Location
    houston, texas
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: Userform possibility question

    I have a budget application: The user inputs workers, the workers levels (level 1, 2, 3,4). costs, and periods (period A, B, C, D) then it opens a new worksheet showing summaries. One of the summaries I work with is by period by worker level. This shows the percent of each worker level being used for each period (i.e. period A has worker level 1 working 50% of the time and 2 working 25% and 3 working 25%; since worker level 1 costs more you might want him working less and worker 3 working more.) I want to make the application more dynamic.

    What I want to do is to allow the user to change the percent worked from the summary worksheet. However since there might be three workers at level 1 and you cant just adjust their time across the board i need to go down to a more granular level.

    This is what I have so far:
    I will use a double click event to open a userform. It will search the selected field for the row and find all the corresponding data to populate the userform. Then it will search the first worksheet to count the number of workers at each level using a loop. Originally I wanted to use this number to add additional labels and spin boxes however the idea of making them visible has some promise. My problem is This is my first time working with VBA excel userforms and I need some advice. If possible could someone show me how to alter the properties of userform at runtime?

    RoyUK - Does this clear up everything?
    Last edited by benfinn; 06-19-2011 at 03:50 PM.

+ 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