+ Reply to Thread
Results 1 to 2 of 2

Need Help Changing the Color of an Object in Sheet1, from a cell in Sheet2 using VBA!

  1. #1
    Registered User
    Join Date
    09-12-2012
    Location
    Las Vegas
    MS-Off Ver
    Excel 2010
    Posts
    2

    Need Help Changing the Color of an Object in Sheet1, from a cell in Sheet2 using VBA!

    Before I get started, I know this is a tall order...haha. I also know that this type of question has been answered and revisited time and time again. I found a lot of useful posts, but would really like something specific to what I'm doing.

    I have an Oval (Oval 1) in Sheet1, and I'd like to change it's color from cell A1 in Sheet2 using VBA.
    The colors are: Red- (255, 0, 0)
    Yellow- (255, 255, 109)
    Green- (41, 247, 46)
    and Grey- (127, 127, 127)

    I'd like these colors to Fill the Oval object. I'm not too worried about the line color at this point.

    Can anyone help with the coding? I'm lost.

  2. #2
    Registered User
    Join Date
    09-12-2012
    Location
    Las Vegas
    MS-Off Ver
    Excel 2010
    Posts
    2

    Re: Need Help Changing the Color of an Object in Sheet1, from a cell in Sheet2 using VBA!

    Ok, here's what I've come up with so far:

    Sub Oval1(ByVal Target As Range)
    'Set Target = Range("A1")


    If UCase(Range("A1").Value) = "GREEN" Then
    ActiveSheet.ChartObjects("Sheet1").Activate
    ActiveChart.Shapes("Oval 1").Fill.ForeColor.RGB = RGB(41, 247, 46)
    End If
    If UCase(Range("A1").Value) = "RED" Then
    ActiveSheet.ChartObjects("Sheet1").Activate
    ActiveChart.Shapes("Oval 1").Fill.ForeColor.RGB = RGB(255, 0, 0)
    End If
    If UCase(Range("A1").Value) = "YELLOW" Then
    ActiveSheet.ChartObjects("Sheet1").Activate
    ActiveChart.Shapes("Oval 1").Fill.ForeColor.RGB = RGB(255, 255, 109)
    End If

    End Sub

    Can anyone tell me what's wrong with this code? I keep getting the error "Arguement not optional".

    Thanks Again.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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