+ Reply to Thread
Results 1 to 12 of 12

Hover over button and change it's colour

  1. #1
    Registered User
    Join Date
    03-15-2008
    Posts
    10

    Hover over button and change it's colour

    hey i need a button to run a macro but i don't like the standard plain grey buttons that excel offers. i saw a friend using one in his project but don't want to ask him how he did it as it would be considered copying. i will add an image to explain my specifications. there must be an easier way than having to design it and you vba to code the colour change.

    \1

    thanks in advance and im sorry if this is a n00bish question.

  2. #2
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    See if links and attachment helps

    http://www.bettersolutions.com/excel...A928011611.htm
    http://www.bettersolutions.com/excel...B926422321.htm
    http://www.bettersolutions.com/excel...T423111411.htm

    VBA Noob
    Attached Files Attached Files
    _________________________________________


    Credo Elvem ipsum etian vivere
    _________________________________________
    A message for cross posters

    Please remember to wrap code.

    Forum Rules

    Please add to your signature if you found this link helpful. Excel links !!!

  3. #3
    Registered User
    Join Date
    03-15-2008
    Posts
    10
    thanks for the quick response. going to try it out now!

  4. #4
    Registered User
    Join Date
    03-15-2008
    Posts
    10
    im having trouble as im running excel 2007 and all the menus are different. could anyone please help me who is using excel 2007 please?

    edit: i think im on to it now. i made a shape wit text on. just need to know how to implement the colour change upon click.
    Last edited by gpcool; 03-15-2008 at 08:17 AM.

  5. #5
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988

  6. #6
    Registered User
    Join Date
    03-15-2008
    Posts
    10
    yeh all the links helped me a lot.

    Now i have a shape that looks like the image in the picture in my opening post. when i click on it a macro runs properly. So the button works, however i would like to get it to change colour (see image in OP) before it runs the macro. How will i do this?

  7. #7
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    Try something like

    Where Autoshape 1 is your shape name

    Please Login or Register  to view this content.

    VBA Noob

  8. #8
    Registered User
    Join Date
    03-15-2008
    Posts
    10
    thanks vba for being such a great help!

    I want to improve the button as much as possible. could someone tell me the code so that when ur mouse hovers over the button it changes colour and when your mouse goes off it returns back.

    would also like to know if i could change it so that it goes to a shape with a bevel to one without. my image should explain.
    \1

    thats what i effectively want to do. If anyone could upload a spreadsheet with it ready made or just tell me the code that would be absolutely brilliant. thanks.

  9. #9
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    See attached which I found

    VBA Noob
    Attached Files Attached Files

  10. #10
    Forum Contributor Portuga's Avatar
    Join Date
    02-20-2004
    Location
    Portugal
    MS-Off Ver
    365
    Posts
    852
    I had the same issue and I discovered you can also have anything working as a macro, even a picture.

    You can also create a button in paint, photoshop,any Jpg, gif you find online, any shape from the draw menu in excel, the logo of the company you are working for, etc and have it working the macro you want.

    Right click on the shape,button, picture, logo and select "Assign Macro" and assign the macro you want. When you click in it, it will run the macro.
    If you found the solution to your question. Mark the thread as "Solved"
    Thank everyone that helped you with a valid solution by clicking on their

    There is no such thing as a problem, only a temporary lack of a solution

  11. #11
    Registered User
    Join Date
    03-15-2008
    Posts
    10
    vba i looked through the code and i can;t figure out the right way to put the code.


    i think it should be:
    assume commandbutton1 is the button that is changing upon hovering and is blue already (50,50,255).

    PHP Code: 
    Private Sub CommandButton1_MouseMove()

         If 
    CommandButton1.BackColor <> RGB(5050255Then
         
           CommandButton1
    .BackColor RGB(5050255)
           
        
    End If
        
    CommandButton1.backcolour RGB(200200200)
    End Sub 
    i'm not good at visual basic so i need someone to check it please!

  12. #12
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    This example uses a commandbutton and also a Label.

    A button doesn't trigger an event so you need to place a Label over the button and make it transparent as per the example and reference in the code

    I would suggest using this code

    Please Login or Register  to view this content.

    Please Login or Register  to view this content.
    HTH

    VBA Noob

+ 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