+ Reply to Thread
Results 1 to 2 of 2

Excel 2016: Changing the Colour of a shape to a non standard colour

Hybrid View

  1. #1
    Registered User
    Join Date
    08-01-2012
    Location
    London
    MS-Off Ver
    Excel 2007
    Posts
    11

    Excel 2016: Changing the Colour of a shape to a non standard colour

    Private Sub Worksheet_Change(ByVal Target As Range)
    'Updateby Extendoffice 20160704
        If Intersect(Target, Range("A1")) Is Nothing Then Exit Sub
        If IsNumeric(Target.Value) Then
            If Target.Value < 100 Then
                ActiveSheet.Shapes("srRectangle1").Fill.ForeColor.RGB = vbRed
            ElseIf Target.Value >= 100 And Target.Value < 200 Then
                ActiveSheet.Shapes("srRectangle1").Fill.ForeColor.RGB = vbYellow
            Else
                ActiveSheet.Shapes("srRectangle1").Fill.ForeColor.RGB = vbGreen
            End If
        End If
    End Sub
    Hi All

    I found the above code online which nearly suits my purpose, but I want to adapt the following line to something like

     ActiveSheet.Shapes("srRectangle1").Fill.ForeColor = RGB(255, 0, 0)
    But this doesn't work, can anyone tell me how I can use any RGB code for the colour rather than just the stand vb colours?

    Thx in advance!

  2. #2
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,863

    Re: Excel 2016: Changing the Colour of a shape to a non standard colour

    Use:
     ActiveSheet.Shapes("srRectangle1").Fill.ForeColor.RGB = RGB(255, 0, 0)
    Best Regards,

    Kaper

+ 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. Replies: 11
    Last Post: 01-16-2018, 09:03 AM
  2. Changing shape and font colour based on text
    By cristihendrix in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 11-23-2017, 06:51 AM
  3. Macros assigned Shape, colour changing code needed please
    By lcartwright in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-14-2014, 05:36 AM
  4. Replies: 3
    Last Post: 02-13-2014, 06:31 AM
  5. changing all text boxes of one fill colour to another colour
    By was0696 in forum Word Formatting & General
    Replies: 3
    Last Post: 02-18-2010, 05:57 AM
  6. [SOLVED] Changing Shape colour by a click?
    By ttwilliams@xtra.co.nz in forum Excel General
    Replies: 4
    Last Post: 10-27-2005, 05:05 AM
  7. Changing the Colour of an Auto Shape (Line)
    By d.i.barr in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-23-2005, 05:48 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