autoshapes vba performance dashb
The UK's Number 1 for Microsoft Office Training Add this page to your favourites/bookmarksBookmark page
 
View printable version of pagePrintable version
Plus One Google
Customer: Sign in
Delegate: Sign in
Trainer: Log in

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

Autoshapes VBA on Performance Dashboard

resolvedResolved · Urgent Priority · Version 2003

replyReply Fri 10 Sep 2010, 12:51Delegate Gary said...

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

For upcoming training course dates see: Pricing & availability

replyReply Mon 13 Sep 2010, 11:00Trainer Anthony said...

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

replyReply Mon 20 Sep 2010, 09:15Delegate Gary said...

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

 

Please browse our web site to find out more about
excel consultant and other Microsoft training courses.

Excel tip:

Change Excel's default font

You can change the default font and font size for all spreadsheets created in Excel by:

1. Going to Tools on the menu bar.
2. Select Options, then General.
3. Next to Standard Font you can change the font and font size.
4. Click OK.

Each new file you start from this point onward should use the font and font size you have selected.

View all Excel hints and tips


Microsoft Certified Partner Accredited Training Provider: Institute of IT Training Institute of Leadership and Management - Certified Courses Security Seal verified by visa, mastercard securecard