+ Reply to Thread
Results 1 to 10 of 10

Can background color of frame change on userform by combobox selection on userfor

  1. #1
    Registered User
    Join Date
    11-08-2011
    Location
    bergen county, NJ
    MS-Off Ver
    Excel 2007
    Posts
    72

    Can background color of frame change on userform by combobox selection on userfor

    I have 4 frames on a userform, each containing the option buttons for grading a student, 1 student per frame.

    what i'd really like to happen is that when a teacher selects his/her class from the combobox on the userform, the frames for the students in that class change to red...

    it would be really sweeeet, if then, when the teacher clicks a button in the red frame, the frame turns to green... (at the moment, it seems easiest to have ALL students have a frame on the userform... the color change would signal the teacher where to go, and the subsequent change from red to green would remind him/her that a choice was made)

    i'm attaching the workbook. i haven't attempted any code yet (actually i tried a few things but nothing worked). i have populated the comboboxes though...

    any help would be so much appreciated !
    this site rules !!!

    -rob
    Attached Files Attached Files
    Last edited by teacher_rob; 11-12-2011 at 11:27 AM.

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Can background color of frame change on userform by combobox selection on userfor

    There are no userforms, no comboboxes. Did you attach the right thing?
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Can background color of frame change on userform by combobox selection on userfor

    As long as I'm thinking about it, this code will turn the frame red. You would add this to the Click event for the button (or every button, if there are more than one that you want to trigger this behavior) inside the frame.

    Please Login or Register  to view this content.
    RGB is a red/green/blue color generator and you can tweak it to make it whatever color you want.

  4. #4
    Registered User
    Join Date
    11-08-2011
    Location
    bergen county, NJ
    MS-Off Ver
    Excel 2007
    Posts
    72

    Re: Can background color of frame change on userform by combobox selection on userfor

    hey,
    i just checked to make sure i didn't post the wrong file... this one is the one.
    i had to get tot the vba tool bar, and then "view object" or "view code" and then F5

    i understand your post about adding the color change when an option button is clicked, but what i'd really like to happen is when a class is selected that the frames corresponding to only the students in that class are highlighted by changing the color in the frame.

    i guess the question is, where does the line of code for a color change go ? the userform is already open... the color change would occur when the user selects a class from the combobox...

    is this possible ?

  5. #5
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Can background color of frame change on userform by combobox selection on userfor

    I see no userform and no code of any kind in this file. Here is what I see in the code development window.

    where does the line of code for a color change go ? the userform is already open... the color change would occur when the user selects a class from the combobox...
    The line of code to change color would be in the event handler for a combobox change.

    I also noticed that your profile says you are using 2007 but this file is 2003 format.
    Attached Images Attached Images

  6. #6
    Registered User
    Join Date
    11-08-2011
    Location
    bergen county, NJ
    MS-Off Ver
    Excel 2007
    Posts
    72

    Re: Can background color of frame change on userform by combobox selection on userfor

    my school uses a service called "classlink". usually i can log into the server from home and use the virtual desktop to do everything i do at school (including excel 2007). apparently they are "experienceing technical difficulties" this weekend, and as such, i'm forced to work with my version of excel at home.

    when i open this file here, i click the vb editor and hit F5 and i get the user form. I've yet to add any code, as the only thing i was trying to do was get the 4 frames, each containing the 9 option buttons, to change color based on the selection of one of the combo boxes...

    i'm going to be working on this all day, so i'll see if i can figure out even how to start this

  7. #7
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Can background color of frame change on userform by combobox selection on userfor

    Quote Originally Posted by teacher_rob View Post
    when i open this file here, i click the vb editor and hit F5 and i get the user form.
    What do you mean by "click the vb editor and hit F5"? And I mean what do you do exactly? In the VBA editor, F5 causes the current Sub to run, or prompts you to select one to run. And when I do that in your file, there are no macros in the list.

    As a last resort attach a screen shot showing the very last thing you see before you bring the user form up.

    I am sure you have a problem that is very simple to solve and I would hate to see you spending enormous time on this when I could get you going in 10 minutes.

    (By the way, you mention your school. Are you a teacher, or are you doing this as an Excel homework assignment? The forum kind of frowns upon doing people's homework for them.)

  8. #8
    Registered User
    Join Date
    11-08-2011
    Location
    bergen county, NJ
    MS-Off Ver
    Excel 2007
    Posts
    72

    Re: Can background color of frame change on userform by combobox selection on userfor

    I think i figured it out !
    I definitely will have more questions, soon, but this is a very good start !
    thanks for your help !!!

    Please Login or Register  to view this content.
    End Sub

  9. #9
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Can background color of frame change on userform by combobox selection on userfor

    Well, congratulations, although I'm still puzzling over what you're doing if I can't see any code.

    And--is this your job or your homework?

    Anyway, your code is functionally correct but I have a stylistic suggestion that makes it a little easier to read and maintain:
    Please Login or Register  to view this content.

  10. #10
    Registered User
    Join Date
    11-08-2011
    Location
    bergen county, NJ
    MS-Off Ver
    Excel 2007
    Posts
    72

    Re: Can background color of frame change on userform by combobox selection on userfor

    6-string,
    I'm a new math teacher. It was frustrating as all get out to see the way this school handled certain aspects of grading, so i had to open my mouth and say "i could automate this whole process..." at the very least, it's an excuse to learn vba...

    i'm also a life-long guitarist. i was a classical guitar minor at the hartt school of music.

+ 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