+ Reply to Thread
Results 1 to 3 of 3

Change Shape's Color upon entries in a Cell

Hybrid View

DesCmCn Change Shape's Color upon... 09-15-2014, 03:59 PM
LJMetzger Re: Change Shape's Color upon... 09-16-2014, 04:53 PM
DesCmCn Re: Change Shape's Color upon... 09-18-2014, 02:41 PM
  1. #1
    Registered User
    Join Date
    09-15-2014
    Location
    Cincinnati Ohio
    MS-Off Ver
    2013
    Posts
    2

    Change Shape's Color upon entries in a Cell

    2 Things:
    1. Can we rename Excel shapes' names in vba Excel 2013?

    2. In the example below I have C6 for the cell to enter a value "Yes" in order to change the color of the star. I plan to make an addition to the code that says if "No" then make the star a (different) color. This is the point that I am at, it doesn't do anything, would like help, please:

    #Sub ColorChangeStar()

    Dim TempSht As String

    For Each Worksheet In ActiveWorkbook.Worksheets
    TempSht = Worksheet.Name
    If ActiveSheets(ShapeChangeColor).Range("C6").Value = "Yes" Then
    With ActiveSheet.Shapes.Range(Array("5-Point Star 1")).Select
    .ThemeColor = xlThemeColorAccent6 '
    .TintAndShade = -0.249977111117893 '
    End With
    End If
    Next Worksheet

    End Sub#

    __
    Thank you.
    Last edited by DesCmCn; 09-18-2014 at 02:39 PM.

  2. #2
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: Change Shape's Color upon entries in a Cell

    Hi DesCmCn and welcome to ExcelForum.com,

    When you post code, you need 'code tags', otherwise the moderators won't let us answer your questions. See the forum rules for instructions: http://www.excelforum.com/forum-rule...rum-rules.html


    The following code (tested and working in Excel 2003) may help you:
    Option Explicit
    
    Public Sub GetSelectedShapeName()
    
      Dim sShapeName As String
      
      On Error Resume Next
      sShapeName = Application.Selection.Name
      If Err.Number = 0 Then
        MsgBox "The name of the Shape selected Is '" & sShapeName & "'."
      Else
        MsgBox "There was no Shape selected."
      End If
      
      On Error GoTo 0
    End Sub
    
    Public Sub RenameSelectedShapeName()
    
      Dim sShapeName As String
      Dim sNewShapeName As String
      
      sNewShapeName = "xxxx"
      
      On Error Resume Next
      sShapeName = Application.Selection.Name
      If Err.Number = 0 Then
        Application.Selection.Name = sNewShapeName
        MsgBox "The Old name of the Shape selected: '" & sShapeName & "'." & vbCrLf & _
               "The New name of the Shape selected: '" & Application.Selection.Name & "'."
      Else
        MsgBox "There was no Shape selected."
      End If
      
      On Error GoTo 0
    End Sub
    
    Sub ColorChangeStar()
      'This changes the color of a specific Shape Name based on the value in cell 'C6' of the sheet the shape is in
      '
      'NOTE: Excel 2003 doesn't support 'Themecolor' and 'TintAndShade'
      'ThemeColor reference:  http://www.excelbanter.com/showthread.php?t=250015
    
      Dim wks As Worksheet
      Dim sSheetName As String
    
      Dim sShapeName As String
      sShapeName = "xxxx"
        
    
      For Each wks In ActiveWorkbook.Worksheets
        
        If wks.Range("C6").Value = "Yes" Then
          wks.Shapes(sShapeName).Fill.ForeColor.RGB = vbYellow
          'wks.Shapes(sShapeName).Fill.ForeColor.ObjectThemeColor = msoThemeColorAccent6   'NOT TESTED
          'wks.Shapes(sShapeName).Fill.ForeColor.TintAndShade = -0.249977111117893         'NOT TESTED
        Else
          wks.Shapes(sShapeName).Fill.ForeColor.RGB = vbGreen
          'wks.Shapes(sShapeName).Fill.ForeColor.ObjectThemeColor = msoThemeColorAccent6   'NOT TESTED
          'wks.Shapes(sShapeName).Fill.ForeColor.TintAndShade = -0.249977111117893         'NOT TESTED
        End If
        
      Next wks
    
    End Sub
    Lewis

  3. #3
    Registered User
    Join Date
    09-15-2014
    Location
    Cincinnati Ohio
    MS-Off Ver
    2013
    Posts
    2

    Re: Change Shape's Color upon entries in a Cell

    Thank you LJMetzger,

    My apologies for the mistake, this seemed to have gone over my head. I edited the post before.

    I will try to implement your suggestion, as I have not been able to make it work yet.

+ 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. [SOLVED] Change Shape Fill Color Based on Cell Value
    By Justair07 in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 11-28-2013, 09:35 AM
  2. Change Shape Color based on Cell Values
    By obriend in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-22-2013, 03:26 AM
  3. Change shape fill color depending on cell value
    By xe-dingo in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 09-05-2013, 03:46 AM
  4. Add command button to shape and change shape color on mouseover
    By maacmaac in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-26-2012, 05:12 PM
  5. Change shape color on mouseover
    By grime in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-27-2007, 02:57 PM

Tags for this Thread

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