Forum Discussion
rodsan724
Oct 27, 2021Brass Contributor
When I click a cell, how can I use VBA to move my shape to the bottom center of selected cell?
When I click any cell, how do I use VBA and cell selected event to move my shape to the bottom center of selected cell? For that matter, would it be much different to any of the sides of the selected cell?
Ah, OK.
Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Target.CountLarge > 1 Then Exit Sub With Me.Shapes(1) .Top = Target.Top + Target.Height - .Height .Left = Target.Left + (Target.Width - .Width) / 2 End With End Sub
5 Replies
Hold down the left Alt key while moving or resizing the shape. It will then snap to the cell edges.
- rodsan724Brass Contributor
I was thinking more like when you helped me with VBA to do this. So it would be in the Cell Selected Event [Previous help you gave me]. I reworded OP.
Ah, OK.
Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Target.CountLarge > 1 Then Exit Sub With Me.Shapes(1) .Top = Target.Top + Target.Height - .Height .Left = Target.Left + (Target.Width - .Width) / 2 End With End Sub