Forum Discussion

rodsan724's avatar
rodsan724
Brass Contributor
Oct 27, 2021
Solved

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?

 

 

  • 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

5 Replies

      • HansVogelaar's avatar
        HansVogelaar
        MVP

        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

Resources