+ Reply to Thread
Results 1 to 12 of 12

Making userform rows visible with a command button

  1. #1
    Registered User
    Join Date
    05-29-2012
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    52

    Making userform rows visible with a command button

    Hello,

    In my userform, I've got 18 rows, each with 5 textboxes and one combobox. The first row has them labeled TextBox3 - TextBox7 and ComboBox1.

    The next row has them labeled TextBox8 - TextBox12 and ComboBox2 and it goes on in the same sequence.

    I need to make a command button so that, when pressed, it makes an entire row visible. Another press of the button should make another row visible and so on. I've got my pseudo-code idea below:


    i = 3
    k = 1
    for every press of commandbutton3,
    TextBox(i).Visible To textbox(i + 4).Visible = True
    ComboBox(k).Visible = True
    i = i + 5
    k = k + 1
    Last edited by GalmOne; 06-14-2012 at 08:43 AM.

  2. #2
    Valued Forum Contributor
    Join Date
    08-29-2011
    Location
    Mississauga, CANADA
    MS-Off Ver
    Excel 2010
    Posts
    503

    Re: Making userform rows visible with a command button

    why not to increase the form's height when that button is clicked?
    upload the file and i will do it for you
    Regards,
    Khaled Elshaer
    www.BIMcentre.com

    Remember To Do the Following....
    1. Thank those who have helped you by clicking the Star below their post.
    2. Mark your post SOLVED if it has been answered satisfactorily:
    • Select Thread Tools (on top of your 1st post)
    • Select Mark this thread as Solved

  3. #3
    Registered User
    Join Date
    05-29-2012
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    52

    Re: Making userform rows visible with a command button

    Thank you, but I have to keep the form height the same because of the other boxes and controls inside. Something like this (although I'm sure that the dim as Range is wrong):

    Please Login or Register  to view this content.
    Last edited by GalmOne; 06-14-2012 at 09:27 AM.

  4. #4
    Valued Forum Contributor
    Join Date
    08-29-2011
    Location
    Mississauga, CANADA
    MS-Off Ver
    Excel 2010
    Posts
    503

    Re: Making userform rows visible with a command button

    you can move them with every click.
    See the attached file. Go to the extra tab Named "Khaled Elshaer" and click the "Enter Hours" button.
    Select a code from the "Activity ID 1" combobox and press tab then you will see the form expanding and the controls moved.
    Sorry I have the code password protected as it's a program that I have made for one of my clients.
    Please upload your file so I can help
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    05-29-2012
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    52

    Re: Making userform rows visible with a command button

    Ok I've attached it below. It's a little crazy, but the "Discrepancies" category in the UserForm has way too many entries, so that's why I want to hide each row until a button is pressed.

    My attempt at this is shown after the very first "End Sub", but I know it won't work mainly because it is unable to update my counters (which are o and p here, instead of i and j).

    DB_Prototype - Copy.xlsm

    EDIT: I saw your form. That's pretty awesome! Yes, I wouldn't mind doing that, but because my form is already gigantic and has many other things on it, I'd prefer it stays the same size. But if I can't do that, I don't mind using your code either.

  6. #6
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Making userform rows visible with a command button

    Perhaps:
    Please Login or Register  to view this content.
    Remember what the dormouse said
    Feed your head

  7. #7
    Valued Forum Contributor
    Join Date
    08-29-2011
    Location
    Mississauga, CANADA
    MS-Off Ver
    Excel 2010
    Posts
    503

    Re: Making userform rows visible with a command button

    Here you go
    Attached Files Attached Files

  8. #8
    Registered User
    Join Date
    05-29-2012
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    52

    Re: Making userform rows visible with a command button

    Thanks Kelshaer and romperstomper! Both of your codes worked perfectly!

    All I needed was the static variable property and the Control property. Now, does declaring something as "Static" retain the variable value indefinitely? Or does it only work for that one button you appended it inside of?

    I'd like to use the final value of "counter" so that I can remove rows using another button as well, from the last row to the top row. I used your code and put "False" in place of each "True", but of course, as I expected, the rows are removed from top to bottom.
    Last edited by GalmOne; 06-14-2012 at 10:56 AM.

  9. #9
    Valued Forum Contributor
    Join Date
    08-29-2011
    Location
    Mississauga, CANADA
    MS-Off Ver
    Excel 2010
    Posts
    503

    Re: Making userform rows visible with a command button

    the counter curRow is available anywhere in the form

  10. #10
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Making userform rows visible with a command button

    A variable declared static in a routine only has scope within that routine. If you want to use it from multiple places, just Dim it above all routines.

  11. #11
    Registered User
    Join Date
    05-29-2012
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    52

    Re: Making userform rows visible with a command button

    Ah, that makes sense. Thank you both very much! I'm going to experiment with your codes for now so I can understand them more before I reuse them for other buttons.

  12. #12
    Valued Forum Contributor
    Join Date
    08-29-2011
    Location
    Mississauga, CANADA
    MS-Off Ver
    Excel 2010
    Posts
    503

    Re: Making userform rows visible with a command button

    u r welcome, Please mark this thread as SOLVED

+ 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