I am adding some buttons to my Excel Sheet dynamically with the following VBA code
Set btn = ActiveSheet.Buttons.Add(ActiveCell.Left, ActiveCell.Top, ActiveCell.Width, ActiveCell.Height)
With btn
.Left = ActiveCell.Left + 0.5
.Top = ActiveCell.Top + 0.5
.OnAction = "DeleteRow"
.Characters.Text = "-"
.Placement = xlMoveAndSize
With .Font
.Name = "Arial"
.FontStyle = "Bold"
.Size = 10
.ColorIndex = 1
End With
End With
If I then sort my rows the buttons dont get sorted, i.e they dont stick with the row they were with before the sort
If I delete a row the button seems to shrink and hide behind a button in another row
How can I make the buttons stay with the rows they were in and get sorted/deleted accordingly?
Set btn = ActiveSheet.Buttons.Add(ActiveCell.Left, ActiveCell.Top, ActiveCell.Width, ActiveCell.Height)
With btn
.Left = ActiveCell.Left + 0.5
.Top = ActiveCell.Top + 0.5
.OnAction = "DeleteRow"
.Characters.Text = "-"
.Placement = xlMoveAndSize
With .Font
.Name = "Arial"
.FontStyle = "Bold"
.Size = 10
.ColorIndex = 1
End With
End With
If I then sort my rows the buttons dont get sorted, i.e they dont stick with the row they were with before the sort
If I delete a row the button seems to shrink and hide behind a button in another row
How can I make the buttons stay with the rows they were in and get sorted/deleted accordingly?