VBA and shapes, man! It's all about the shapes!

RockandGrohl

Well-known Member
Joined
Aug 1, 2018
Messages
671
Office Version
  1. 2010
Platform
  1. Windows
Hi ladies and gents.

I have a sheet with various metrics on it (15 in total)

According to the variance from last month, these will either have a RedUp, RedDown, GreenUp, GreenDown or GreySame box with an inside arrow (grouped shapes)

Don't worry too much about that, I will have to do it line by line for each of the 15 metrics and work out is it a profit increase (green up) a cost increase (red up) etc, that sort of thing.




I have these five grouped shapes sat in the top of the worksheet, and when I need one, I want to duplicate it, and then move that named version into place. But first, I need to delete all shapes that aren't the original five.

Here's what I have so far:

VBA Code:
Set s = ActiveSheet.Shapes("RedUp")

Set s = s.Duplicate


With s
    .Top = Range("B9").Top
    .Left = Range("C9").Left - 27.5
End With

The problem here is that when I duplicate the shape, it retains the original name of "RedUp" - it would be good to call it "RedUpCopy" and then at the start of the module I can simply purge any shapes that have "copy" in the name.

Thanks! Leslie, there's not a single shape in that painting!
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.

RockandGrohl

Well-known Member
Joined
Aug 1, 2018
Messages
671
Office Version
  1. 2010
Platform
  1. Windows
Ah! This looks promising:

VBA Code:
Set s = ActiveSheet.Shapes("RedUp")

With s.Duplicate
    .Name = s.Name & "Copy"
    .Top = Range("B9").Top
    .Left = Range("C9").Left - 27.5
End With
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,152,110
Messages
5,768,156
Members
425,458
Latest member
Jaspal1996

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top