Results 1 to 11 of 11

Change Color of a Shape With Click

Threaded View

Quamdar Change Color of a Shape With... 10-08-2009, 12:59 PM
Quamdar Re: Change Color of a Shape... 10-08-2009, 02:13 PM
shg Re: Change Color of a Shape... 10-08-2009, 02:48 PM
Quamdar Re: Change Color of a Shape... 10-08-2009, 03:13 PM
shg Re: Change Color of a Shape... 10-08-2009, 03:27 PM
Quamdar Re: Change Color of a Shape... 10-09-2009, 07:56 AM
eyong123 Re: Change Color of a Shape... 09-21-2011, 02:32 PM
  1. #1
    Registered User
    Join Date
    10-06-2009
    Location
    Cincinnati, Ohio
    MS-Off Ver
    Excel 2003
    Posts
    10

    Change Color of a Shape With Click

    what i am trying to do is toggle the color of a shape between red and green. what i have currently (courtesy of a search on this site) is this macro:

    Sub Oval2_Click()
    If ActiveSheet.Shapes("Oval 2").Fill.Visible = msoFalse Then
    ActiveSheet.Shapes("Oval 2").Fill.Visible = msoTrue
    Else
    ActiveSheet.Shapes("Oval 2").Fill.Visible = msoFalse
    End If
    End Sub
    it works great when attached to the shape but the only problem is it toggles between no-fill and white. i am assuming i would change it to something along the lines of this:

    Sub ShapeClick()
    If ActiveSheet.Shapes("Oval 3").Fill.ColorInex = Red Then
    ActiveSheet.Shapes("Oval 3").Fill.ColorIndex = Green
    Else
    ActiveSheet.Shapes("Oval 3").Fill.ColorIndex = Red
    End If
    End Sub
    the only problem is i haven't worked with macros in excel before so i don't know what the actual code is for setting it to a color so it obviously won't work.

    any help would be very much appreciated, thanks.

    PS also i am going to need to do the same thing but instead of filling with a color i am going to need the fill for a shape to toggle between two pictures. Not 100% sure that will be possible though since no everyone that has the excel file will have those files on their computer in the same spot but thought there might be some way to attach them to the excel template.
    Last edited by Quamdar; 10-09-2009 at 11:53 AM.

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