VBA to align shapes

Giordano Bruno

Well-known Member
Joined
Jan 7, 2007
Messages
1,341
I have a sheet which contains a number of shapes. Some of their names start with "Help". When I change computers, the shapes change their width. I want them all to have the same width and to be aligned to the right of their respective cells. but cannot find how to do this. An alternative is to select all "Help" shapes and align them with each other. To do that, I need to select all, but only, "Help" shapes. If anyone can help me with this I would be grateful.
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
Hello,

To get you started about how to Loop Shapes in your worksheet
VBA Code:
Sub LoopShapes()
Dim shp As Shape
Dim wsh As Worksheet

Set wsh = ThisWorkbook.Worksheets("Sheet1")
    If wsh.Shapes.Count > 0 Then
        'Loop through all the shapes on the sheet
        For Each shp In wsh.Shapes
            If UCase(Left(shp.Name, 4)) = "help" Then
            '
            ' insert your actions
            '
            End If
        Next shp
    Else
        MsgBox "No Shape in this WorkSheet"
    End If
End Sub
 
Upvote 1
Many thanks James. It actually gets me finished as I've found the following from ChrisM elsewhere on this site.

Most programming is done with only Top and Left references. To get bottom and right, you use Height and Width and add those to Top/Left.
ActiveSheet.Shapes("Picture 1").Left = Range("J2").Left + Range("J2").Width

Thanks again and thanks to ChrisM. Problem solved.
 
Upvote 0
Very glad to hear you have managed to sort it out (y)
:)
 
Upvote 0

Forum statistics

Threads
1,214,653
Messages
6,120,750
Members
448,989
Latest member
mariah3

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