×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Filling in autoshapes

Filling in autoshapes

Filling in autoshapes

(OP)
I'm trying to fill in a Autoshape in excel based on the result of a calculation.

i.e. if cell B1>0 then fill in autoshape 136 with red.

I am using this code:

Private Sub Worksheet_Calculate()
    Dim ThisWS As Worksheet
    
    Set ThisWS = Me
    If ThisWS.Range("b1") > 0 Then
   ThisWS.Shapes(136).Fill.ForeColor.SchemeColor = 10  ' Red
    Else
        ThisWS.Shapes(136).Fill.ForeColor.SchemeColor = 0
    End If
       
End Sub

When I do this excel returns the message

"run time error (then a bunch of numbers)
The index into the specified collection is out of bounds"

The autoshape is a donut

It seems to work if the autoshape number is lower like 50.

If there is a better way to do this I would appreciate the help.

 

RE: Filling in autoshapes

Private Sub Calculate()

Row = 1 'Row=1
Column = 2 'Column=B

If Cells(Row, Column) > 0 Then

ActiveSheet.Shapes("Donut 1").Select
Selection.ShapeRange.Fill.ForeColor.SchemeColor = 10

Else

ActiveSheet.Shapes("Donut 1").Select
Selection.ShapeRange.Fill.ForeColor.SchemeColor = 0


End If

End Sub

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources