+ Reply to Thread
Results 1 to 6 of 6

Macros assigned Shape, colour changing code needed please

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    02-04-2014
    Location
    NSW, Australia
    MS-Off Ver
    Excel 2010
    Posts
    136

    Macros assigned Shape, colour changing code needed please

    I have made several Shapes and assigned macros to them, all is good.

    What i am curious about: is it possible to highlight or change colour of the shape on press and return to normal if another is shape is pressed? Just anything to make that particular shape stand out that it has been selected then return to normal when another shape has been selected...
    Sub AllLocal()
    '
    ' AllLocal Macro
    '
        Application.ScreenUpdating = False
    '
        Sheets("DATA2").Select
        Range("A2").Select
        Selection.Copy
        Sheets("Main").Select
        Range("H5").Select
        ActiveSheet.Paste
        Range("C6").Select
        Application.ScreenUpdating = True
        
    End Sub
    That is the code so far that is attached to 1x shape...
    Last edited by lcartwright; 03-13-2014 at 08:58 PM.

  2. #2
    Forum Contributor
    Join Date
    02-24-2013
    Location
    California
    MS-Off Ver
    Excel 2010
    Posts
    317

    Re: Macros assigned Shape, colour changing code needed please

    Can't help you out with the shape color change, but this is your recorded code cleaned up.
    Sub AllLocal()
        Application.ScreenUpdating = False
        Worksheets("DATA2").Range("A2").Copy
        Worksheets("Main").Range("H5").PasteSpecial xlPasteAll
        Range("C6").Select
     Application.CutCopyMode = False
        Application.ScreenUpdating = True
    End Sub

  3. #3
    Forum Contributor
    Join Date
    02-04-2014
    Location
    NSW, Australia
    MS-Off Ver
    Excel 2010
    Posts
    136

    Re: Macros assigned Shape, colour changing code needed please

    Thank you for that (Putting "L" plates back on forehead)

  4. #4
    Forum Contributor
    Join Date
    02-24-2013
    Location
    California
    MS-Off Ver
    Excel 2010
    Posts
    317

    Re: Macros assigned Shape, colour changing code needed please

    This will change the color of the shape. You just need to insert the name of the shape between the quotes
     ActiveSheet.Shapes.Range(Array("NAME OF SHAPE GOES HERE")).Fill.ForeColor.SchemeColor = 3
    I think you could then put the same line in the other shape code , but change the number 3 to a different number.
    Last edited by Jim885; 03-13-2014 at 10:07 PM.
    If I helped in any way, please click the star

  5. #5
    Forum Contributor
    Join Date
    02-24-2013
    Location
    California
    MS-Off Ver
    Excel 2010
    Posts
    317

    Re: Macros assigned Shape, colour changing code needed please

    Here ya go. Here's an example of two codes that will switch the colors of two shapes when the shapes are pressed.
    Sub aa()
     ActiveSheet.Shapes.Range(Array("Heart 1")).Fill.ForeColor.SchemeColor = 3
     ActiveSheet.Shapes.Range(Array("5-Point Star 2")).Fill.ForeColor.SchemeColor = 2
    End Sub
    
    Sub ae()
     ActiveSheet.Shapes.Range(Array("Heart 1")).Fill.ForeColor.SchemeColor = 2
     ActiveSheet.Shapes.Range(Array("5-Point Star 2")).Fill.ForeColor.SchemeColor = 3
    End Sub
    Assign the codes to different shapes.
    Last edited by Jim885; 03-13-2014 at 11:14 PM.

  6. #6
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,481

    Re: Macros assigned Shape, colour changing code needed please

    here is an example with 4 shapes. pressed button is in red.

    Sub PressMe()
        Dim vntItem As Range
        
        ActiveSheet.Shapes.Range(Array("Rounded Rectangle 1", "Rounded Rectangle 2", _
                                       "Rounded Rectangle 3", "Rounded Rectangle 4")).Fill.ForeColor.RGB = RGB(100, 100, 100)
        ActiveSheet.Shapes(Application.Caller).Fill.ForeColor.RGB = RGB(255, 0, 0)
        
    End Sub
    Attached Files Attached Files
    Cheers
    Andy
    www.andypope.info

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Automatically bringing a Shape into a Cell Using Shape Code
    By dineshtendulkar in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 12-16-2016, 02:25 PM
  2. Finding selected shape through code
    By DeyAgahi in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-08-2013, 01:14 AM
  3. [SOLVED] Insert Excel Shape at Active Cell - Final help needed Please
    By PeterF in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 12-29-2012, 01:27 PM
  4. Conditional formatting needed for shape colour - is programming needed?
    By Farmboyuk in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-14-2012, 07:27 AM
  5. help needed trying to find autoshape/shape name
    By funkymonkUK in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-23-2006, 11:10 AM

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