+ Reply to Thread
Results 1 to 3 of 3

VBA: Change Shape Color based off cell value

  1. #1
    Registered User
    Join Date
    10-26-2016
    Location
    Chicago
    MS-Off Ver
    Excel 2010
    Posts
    2

    VBA: Change Shape Color based off cell value

    Hello,

    First post. Just getting into using VBA/Macros for Excel. I have ran into a problem. The following macro worked fine with one excel file, and then when I started to reference data from a pivot table I started to get an error. (Error 1004, Method "Range of object'_Global' failed)

    The macro below is to simply change a shape color based off a range value compared to another range value. Can you please take a look and let me know what I am doing wrong.

    Sheet I am referencing is titled: PIVOT Tables
    Shape I am referencing is titled: Chicago

    Thanks!!

    Please Login or Register  to view this content.
    Last edited by Leith Ross; 10-26-2016 at 01:59 PM. Reason: Added Code Tags

  2. #2
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,942

    Re: VBA: Change Shape Color based off cell value

    When your sheet name has a space in it, Excel requires single quotes in any reference to it. So, change all

    Range("PIVOT Tables!xxxx")
    to
    Range("'PIVOT Tables'!xxxx")

    The single quotes go just before the P of PIVOT and just before the !
    Bernie Deitrick
    Excel MVP 2000-2010

  3. #3
    Registered User
    Join Date
    10-26-2016
    Location
    Chicago
    MS-Off Ver
    Excel 2010
    Posts
    2

    Re: VBA: Change Shape Color based off cell value

    Bernie,

    Thanks for the help! That was a quick easy fix.

+ 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. Change Shape's Color upon entries in a Cell
    By DesCmCn in forum Excel General
    Replies: 2
    Last Post: 09-18-2014, 02:41 PM
  2. 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
  3. [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
  4. 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
  5. change color of shape based on value in dropdownlist
    By raketman007 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-07-2013, 09:39 AM
  6. 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
  7. trying to change two or more shape's color based on thier location, please advise
    By nimikipod in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-13-2011, 04:01 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