+ Reply to Thread
Results 1 to 4 of 4

Change color of shapes based on a value on another sheet

  1. #1
    Forum Contributor
    Join Date
    03-18-2013
    Location
    Bulgaria
    MS-Off Ver
    Excel 2010
    Posts
    139

    Change color of shapes based on a value on another sheet

    I have a macro that changes the color of shapes, based on a value on another sheet.

    I have uploaded a test file.

    The thing is that the colors don't change at all. However if I put a cell anywhere on sheet "Draft" and refer it as =Table!A2 and another one =Table!A3 - the macro starts working right away. Although they are not referred anywhere in the macro. When I delete them - macro stops working.

    Any idea why is that?

    Thank you in advance!
    Attached Files Attached Files

  2. #2
    Forum Contributor
    Join Date
    07-07-2013
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    256

    Re: Change color of shapes based on a value on another sheet

    sorry the file is not readalbe
    can u check it out and upload again
    when i open error comes

  3. #3
    Forum Contributor
    Join Date
    03-18-2013
    Location
    Bulgaria
    MS-Off Ver
    Excel 2010
    Posts
    139

    Re: Change color of shapes based on a value on another sheet

    all right, try now!
    Attached Files Attached Files

  4. #4
    Forum Contributor
    Join Date
    03-18-2013
    Location
    Bulgaria
    MS-Off Ver
    Excel 2010
    Posts
    139

    Re: Change color of shapes based on a value on another sheet

    Here is the actual macro:


    Private Sub Worksheet_Calculate()

    Dim rng1 As Range, rng2 As Range

    Set rng1 = Worksheets("Table").Range("A2")
    Set rng2 = Worksheets("Table").Range("A3")

    Dim shp1 As Shape, shp2 As Shape
    Dim bytColor1 As Byte, bytColor2 As Byte

    Set shp1 = Worksheets("Draft").Shapes("Rectangle1")
    Set shp2 = Worksheets("Draft").Shapes("Rectangle2")

    Select Case rng1
    Case 1 To 1.99
    bytColor1 = 2
    Case 2 To 2.99
    bytColor1 = 3
    Case 3 To 3.99
    bytColor1 = 4
    Case 4 To 4.99
    bytColor1 = 5
    Case 5 To 5.99
    bytColor1 = 6
    Case Else
    bytColor1 = 1
    End Select
    Select Case rng2
    Case 1 To 1.99
    bytColor2 = 2
    Case 2 To 2.99
    bytColor2 = 3
    Case 3 To 3.99
    bytColor2 = 4
    Case 4 To 4.99
    bytColor2 = 5
    Case 5 To 5.99
    bytColor2 = 6
    Case Else
    bytColor2 = 1
    End Select
    shp1.Fill.ForeColor.SchemeColor = bytColor1
    shp2.Fill.ForeColor.SchemeColor = bytColor2
    End Sub

+ 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] Looping Sheets to change Color of Shapes
    By Hood in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 04-16-2015, 02:47 PM
  2. Query change the Shapes color by entering value in cell
    By ashokJan in forum Excel General
    Replies: 5
    Last Post: 12-05-2014, 07:09 AM
  3. Shape Color Change Based on Value in different sheet
    By kevinspocket in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-17-2014, 05:50 PM
  4. Change color of shapes based on cell values.
    By rkostner in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 04-24-2013, 05:55 PM
  5. [SOLVED] Change color of text for a group of shapes
    By emiliekatherine in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-27-2012, 08:43 AM
  6. Replies: 1
    Last Post: 04-13-2006, 07:30 PM
  7. [SOLVED] How can I change sheet tab color based on cell value in sheet?
    By SCAScot in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-23-2005, 05:50 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