VBA to create, place and name Shape from Values in cells

platypus007

New Member
Joined
Oct 24, 2019
Messages
13
Hi,
I need help with this: In cells A1:A6 I have Name of Shape In B1:B6 I have refference to another cell in form D2 in cell B1 , E3 in cell B2 , C6 in cell B3 and so on.
I need to create multiple Circular Shapes named after A1:A6 and placed into refference cells, which is in B1:B6 and loop this (creating shapes) till last A value.




https://pasteboard.co/IGvvlj1.jpg

Thanks Viktor
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
30,247
Office Version
365
Platform
Windows
How about
Code:
Sub platypus()
    Dim Shp As Shape
    Dim Cl As Range
    
    For Each Cl In Range("A2", Range("A" & Rows.Count).End(xlUp))
        Set Shp = Sheet12.Shapes.AddShape(msoShapeOval, 1, 1, 10, 10)
        Shp.Name = Cl.Value
        With Range(Cl.Offset(, 1).Value)
            Shp.Top = .Top + (.Height / 2) - 5
            Shp.Left = .Left + (.Width / 2) - 5
        End With
    Next Cl
End Sub
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
30,247
Office Version
365
Platform
Windows
You're welcome
 

Forum statistics

Threads
1,077,822
Messages
5,336,566
Members
399,088
Latest member
Swindlestikz

Some videos you may like

This Week's Hot Topics

Top