Forum Discussion
rodsan724
Oct 18, 2021Brass Contributor
When I click a cell, is it possible to move my shape at the bottom of that cell
When I click a cell, is it possible to move my line shape right underneath that cell (with some VBA magic)?
- Oct 18, 2021
Right-click the sheet tab.
Select 'View Code' from the context menu.
Copy the code listed below into the worksheet module.
Switch back to Excel.
Save the workbook as a macro-enabled workbook.
Make sure that you allow macros when you open the workbook.
P.S. if your sheet contains multiple shapes, you may have to change the index number 1 in Shapes(1).
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 End With End Sub
HansVogelaar
Oct 18, 2021MVP
Right-click the sheet tab.
Select 'View Code' from the context menu.
Copy the code listed below into the worksheet module.
Switch back to Excel.
Save the workbook as a macro-enabled workbook.
Make sure that you allow macros when you open the workbook.
P.S. if your sheet contains multiple shapes, you may have to change the index number 1 in Shapes(1).
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
End With
End Sub
rodsan724
Oct 21, 2021Brass Contributor
Wow! Thanks for this, really cool.