title: Get Button to move with cells in Excel
body: <p>I have a macro in Excel which inserts a new, pre-determined row into a spreadsheet. As part of that process, it inserts a button in the final column, which is programmed to run a macro to perform a specific action on that row.</p>
  
  <p>It is frequently required to sort the worksheet to rearrange the data, but I am finding that when I do so the buttons do not move with their associated row, and the actions become all mixed up.</p>
  
  <p>I have tried setting the properties of the buttons to 'XLMove' but it doesn't work - when the data is sorted the buttons stay put in their original cell.</p>
  
  <p><strong>How can I anchor the button to the cell that they were originally inserted into, so that the sorting moves the buttons as well?</strong></p>
  
  <pre><code>Dim btn As Button
  Set btn = ActiveSheet.Buttons.Add(1173, 257.25, 41.25, 23.25)
  
  With btn
      .Placement = xlMove
      .OnAction = "ButtonRow"
      .Characters.Text = "Action!"
      .Left = ActiveCell.Left
      .Top = ActiveCell.Top
  End With
  </code></pre>