SOLVED

When I click a cell, how can I use VBA to move my shape to the bottom center of selected cell?

Brass Contributor

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?

 

rodsan724_0-1635355288106.png

 

5 Replies

@rodsan724 

Hold down the left Alt key while moving or resizing the shape. It will then snap to the cell edges.

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.

best response confirmed by rodsan724 (Brass Contributor)
Solution

@rodsan724 

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
Wow, you are a master! Is there a resource you recommend for this kind of stuff for beginners like me?
1 best response

Accepted Solutions
best response confirmed by rodsan724 (Brass Contributor)
Solution

@rodsan724 

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

View solution in original post