none
format numbers RRS feed

  • Question

  • Hello all ---------- first time visit.

    I have two shapes (a rectangle and an oval) on an excel sheet acting as buttons to run macros. These buttons sort of work like toggles. I would like to color code or otherwise alert the user which button is currently in use. So, if button 1 is chosen the color turns red while button 2 remains white, and vice versa.

    Thanks

    vinnie49

    Saturday, December 6, 2014 8:33 PM

All replies

  • Let's say that the shapes are named Rectangle 1 and Oval 2. The macros associated with them could look like this:

    Sub Rectangle1_Click()
        ActiveSheet.Shapes("Rectangle 1").Fill.ForeColor.RGB = vbRed
        ActiveSheet.Shapes("Oval 2").Fill.ForeColor.RGB = vbWhite
        ' Other code goes here
        ' ...
    End Sub
    
    Sub Oval2_Click()
        ActiveSheet.Shapes("Oval 2").Fill.ForeColor.RGB = vbRed
        ActiveSheet.Shapes("Rectangle 1").Fill.ForeColor.RGB = vbWhite
        ' Other code goes here
        ' ...
    End Sub


    Regards, Hans Vogelaar (http://www.eileenslounge.com)

    Saturday, December 6, 2014 9:28 PM
  • Hans,

    Thanks for taking the time and including the code. It works just great!

    Happy Holidays to you and yours.

    vinnie24

    Sunday, December 7, 2014 2:05 AM