Public Schedule Face-to-Face & Online Instructor-Led Training - View dates & book

autoshapes vba performance dashb

Forum home » Delegate support and help forum » Microsoft Excel Training and help » Autoshapes VBA on Performance Dashboard

Autoshapes VBA on Performance Dashboard

ResolvedVersion 2003

Gary has attended:
Access VBA course
Excel VBA Advanced course

Autoshapes VBA on Performance Dashboard

Good afternoon

I have created some code that is basically a Select Case statement that gives different autoshapes within a cell for good and bad performance. But, I need to do some code so as when the macro is refreshed it deletes the existing autoshapes and begins again. The code that I have produced is:

Sub arrow()

For Each c In Range("A3:B7")

Select Case c.Value
Case Is = 1
With ActiveSheet.Shapes.AddShape(msoShapeUpArrow, c.Left + c.Width, c.Top, 6, c.Height)
.Fill.ForeColor.SchemeColor = 11
End With
Case Is = 2
With ActiveSheet.Shapes.AddShape(msoShapeDownArrow, c.Left + c.Width, c.Top, 6, c.Height)
.Fill.ForeColor.SchemeColor = 10
End With

Case Is = 3
With ActiveSheet.Shapes.AddShape(msoShapeDownArrow, c.Left + c.Width, c.Top, 6, c.Height)
.Fill.ForeColor.SchemeColor = 10
End With


Case Is = 4
With ActiveSheet.Shapes.AddShape(msoShapeDownArrow, c.Left + c.Width, c.Top, 6, c.Height)
.Fill.ForeColor.SchemeColor = 10
End With

Case Is = 5
With ActiveSheet.Shapes.AddShape(msoShapeDownArrow, c.Left + c.Width, c.Top, 6, c.Height)
.Fill.ForeColor.SchemeColor = 10
End With



End Select

Next c

End Sub


If you could bolt something onto this to enable me to rerun the macro time and time again, that would be appreciated.

Thanks

Gary

RE: Autoshapes VBA on Performance Dashboard

Hi Gary, thanks for your query. Two things come to mind here. First of all you are trying to code the conditional formatting enhancements that come as standard in Excel 2007! However, there's nothing wrong with trying to replicate a work around for 2003, but you might try looking on the net for a free add-in that will do this for you.

However, if you do want to code it consider changing the fill colours of the arrows rather than deleting them out and putting them back in again. Every time you delete them out you are inserting new objects with new index numbers onto the sheet which is why you're having problems identifying the shapes and then deleting them. Just overlay a series of arrows all initially with no fill colour or border and change the formatting of the one you want dependent on the case. This should also work much quicker than continually re-drawing the objects on the screen.

Hope this helps,

Anthony

RE: Autoshapes VBA on Performance Dashboard

Yes, this is the code that I found on the internet also.

How would you centre the arrow in the cell??

Thanks

Gary

 

Training courses

Training information:

See also:

Welcome. Please choose your application (eg. Excel) and then post your question.

Our Microsoft Qualified trainers will then respond within 24 hours (working days).

Frequently Asked Questions
What does 'Resolved' mean?

Any suggestions, questions or comments? Please post in the Improve the forum thread.

Excel tip:

Closing all your workbooks Quickly

Hold the SHIFT key down and using the mouse click on the file menu, it will now now CLOSE ALL rather than close. This closes all workbooks down but still leaves the application open.

View all Excel hints and tips

Connect with us:

0207 987 3777

Call for assistance

Request Callback

We will call you back

Server loaded in 0.1 secs.