Results 1 to 1 of 1

Updating shape colors when opening workbook.

Threaded View

  1. #1
    Registered User
    Join Date
    01-22-2010
    Location
    Norway
    MS-Off Ver
    Excel 2007
    Posts
    33

    Updating shape colors when opening workbook.

    Hi,

    I do not have much experience in VBA, but I assume this should be relatively easy.

    I have multiple shapes which change color depending on the value from certain cells.
    The values within the cells are linked to an external workbook.
    The values within the cells update when I open the shape workbook, but not the actual shape colors.

    - How can I write the code so that the shape colors update automatically when workbook opens (or opens sheet for that matter).

    Following code is written in sheet1 code.

    Private Sub Worksheet_Change(ByVal Target As Range)
    Dim Rng As Range
    Dim ShapeName As String
    Dim SHP As Shape
    
    ShapeName = "A"
    
    Set Rng = ThisWorkbook.Worksheets("Sheet1").Range("R101")
    Set SHP = Rng.Parent.Shapes(ShapeName)
    
    If Rng.Value = "OPEN" Then
    SHP.Fill.ForeColor.RGB = RGB(43, 170, 26) ' green
    End If
    If Rng.Value = "CLOSED" Then
    SHP.Fill.ForeColor.RGB = RGB(255, 0, 0) ' red
    End If
    If Rng.Value = "N/A" Then
    SHP.Fill.ForeColor.RGB = RGB(255, 255, 255) ' white
    End If
    
    ShapeName = "B"
    
    Set Rng = ThisWorkbook.Worksheets("Sheet1").Range("R228")
    Set SHP = Rng.Parent.Shapes(ShapeName)
    
    If Rng.Value = "OPEN" Then
    SHP.Fill.ForeColor.RGB = RGB(43, 170, 26) ' green
    End If
    If Rng.Value = "CLOSED" Then
    SHP.Fill.ForeColor.RGB = RGB(255, 0, 0) ' red
    End If
    If Rng.Value = "N/A" Then
    SHP.Fill.ForeColor.RGB = RGB(255, 255, 255) ' white
    End If
    
    End Sub
    Last edited by xe-dingo; 03-05-2014 at 08:38 AM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Opening & updating another workbook from an open workbook using a macro.
    By FV99 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-19-2012, 06:34 AM
  2. really stuck with auto updating a textbox on opening a workbook
    By markus_87 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-01-2011, 10:06 AM
  3. Opening a worksheet with an auto shape button
    By Mooseman60 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 10-06-2010, 08:21 AM
  4. Updating all pivots when opening workbook
    By JoFo in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 12-23-2008, 11:26 AM
  5. Updating LINKS when opening a workbook
    By Dragon120 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 04-02-2006, 10:30 PM

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