+ Reply to Thread
Results 1 to 5 of 5

shape color fill control with cell value private sub

Hybrid View

canguest shape color fill control with... 10-09-2018, 01:23 PM
Pauleyb Re: shape color fill control... 10-12-2018, 02:15 PM
canguest Sub doesn't work if the... 10-12-2018, 02:32 PM
Fluff13 Re: shape color fill control... 10-12-2018, 03:04 PM
Pauleyb Re: shape color fill control... 10-12-2018, 05:20 PM
  1. #1
    Registered User
    Join Date
    10-27-2016
    Location
    Ontario, Canada
    MS-Off Ver
    2013
    Posts
    5

    shape color fill control with cell value private sub

    I would like to control shape colors to display a dashboard based on cell value resulting from AVERAGE(,,,) formula
    My sub works fine with numeric values.
    Any suggestions are very much appreciated.
    =================================
    Private Sub Worksheet_Change(ByVal Target As Range)

    If Intersect(Target, Range("B5")) Is Nothing Then Exit Sub
    If IsNumeric(Target.Value) Then
    If Target.Value > 0.75 Then
    ActiveSheet.Shapes("Shape1").Fill.ForeColor.RGB = vbGreen
    ElseIf Target.Value < 0.75 And Target.Value >= 0.5 Then
    ActiveSheet.Shapes("Shape1").Fill.ForeColor.RGB = vbYellow
    Else
    ActiveSheet.Shapes("Shape1").Fill.ForeColor.RGB = vbRed

    End If
    End If

    End Sub

  2. #2
    Forum Expert
    Join Date
    06-26-2010
    Location
    Austin, TX
    MS-Off Ver
    Excel 2010
    Posts
    1,673

    Re: shape color fill control with cell value private sub

    What exactly is broken? You say it works with numeric values and AVERAGE is numeric...
    Pauley
    --------
    If I helped with your issue, I'd appreciate a rep bump (hit the '*' icon to the bottom left of this post).

  3. #3
    Registered User
    Join Date
    10-27-2016
    Location
    Ontario, Canada
    MS-Off Ver
    2013
    Posts
    5
    Quote Originally Posted by Pauleyb View Post
    What exactly is broken? You say it works with numeric values and AVERAGE is numeric...

    Sub doesn't work if the formula is in the target cell. Cell must have a numeric value for the sub to work, not a calculated value.
    Thanks

  4. #4
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,950

    Re: shape color fill control with cell value private sub

    Isnumeric will return true if there is a formula in cell, as long as the formula returns a number.

  5. #5
    Forum Expert
    Join Date
    06-26-2010
    Location
    Austin, TX
    MS-Off Ver
    Excel 2010
    Posts
    1,673

    Re: shape color fill control with cell value private sub

    Okay, that is odd. I just tested some similar code, and my target.value is the calculated value. My < and > tests worked as expected.

    Go into the debugger and put a breakpoint on your 'isnumeric' line. When it halts, hover over the text Target.Value with your cursor. What value appears?

+ 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] Code VBA for changing fill color of shape base on data of cells
    By TanNguyen in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-07-2015, 08:39 PM
  2. [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
  3. Change Color of text on a shape to No Fill
    By gkumthekar in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-28-2013, 04:38 PM
  4. 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
  5. [SOLVED] Use a button to control a macro that inserts an image into a shape or resets the shape
    By nwb in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-13-2013, 04:41 PM
  6. [SOLVED] How can I fill color in Group box (form control)
    By anand_erin in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-03-2012, 04:46 PM
  7. Fill Cell with Color from Shape's color code
    By excelnewbie80 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 06-02-2012, 05:34 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