Duplicating shapes using Duplicate.IncrementLeft appears to duplicate in two directions

ajlmau

New Member
Joined
Sep 18, 2022
Messages
2
Office Version
  1. 365
Platform
  1. Windows
I only dabble in VBA and am not experienced. So thank you to whoever reads this and tries to help.

I have a circle shape that I'm trying to duplicate. The number of duplicates required and their spacing are variable cell inputs in the worksheet.
When I run my macro by pressing F8, I have isolated which line of code is malfunctioning. For a little context, I have added the line before and after:

For i8 = 1 To (Range("I13") - 1)
Sheets("4. Column").Shapes.Range(Array("Reo bar layer 8")).Duplicate.IncrementLeft (i8 * Range("I26") / 3.55)
Next i8

What I expect from these 3 lines of VBA code:
When cell I26 is say 120 then the spacing of the duplicates should be 120/3.55 points apart (horizontally)
When cell I13 is say 4, then the duplicate shapes should be 3 in addition to the original shape.

The problem:
The first duplicate shape appears to be offset vertically (by what appears to me by some random amount) when there shouldnt be a vertical component. The following iterative duplicates appear to be functioning well (no vertical offset). Furthermore, the first duplicate is also offset horizontally for amount in addition to the specified amount. I cannot work out why this is happening as the duplicate.IncrementLeft is meant to only be a horizontal duplicate. And to make it more confusing, there was a time when this line of code worked perfectly.

The attached shows what I mean. where the blue filled circle shapes should be bound and equally spaced within the round cornered rectangle. I cant work out why this is happening.

I appreciate the efforts of anyone who can help me!
 

Attachments

  • Macro fail.png
    Macro fail.png
    87.4 KB · Views: 5

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
A correcttion to the line from my original post. It should read:
When cell I13 is say 5, then the duplicate shapes should be 4 in addition to the original shape.
 
Upvote 0

Forum statistics

Threads
1,214,950
Messages
6,122,436
Members
449,083
Latest member
Ava19

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
Back
Top