0

I have created a spreadsheet that allows you to pick an option from a drop down list and then shows some corresponding code. I have created a macro that inserts a new row and shifts the table down, it also adds a button on the end of the inserted row that is meant to delete the row it is on. However, it always deletes the same row. Is there a way to add a macro that deletes the row it is in?

  • 1
    you need to determine what row the button is on/over, something like this may help. https://stackoverflow.com/a/21545710/212869 – NickSlash Feb 28 '22 at 11:30
  • Ok thanks that has helped with the row number for the button. How would you use this to select and delete the entire row? – Ben Allen Feb 28 '22 at 12:38
  • You modify your existing macro to use the row number you find under the button instead of the constant value it likely uses. If you provide your code I may be able to help further however its likely there is a question here on SO that shows you how to remove a chosen\specific row too. – NickSlash Feb 28 '22 at 15:00
  • Does this answer your question? [Excel VBA: getting row of clicked button](https://stackoverflow.com/questions/6242605/excel-vba-getting-row-of-clicked-button) – taylor.2317 Feb 28 '22 at 17:27
  • Please provide enough code so others can better understand or reproduce the problem. – Community Mar 02 '22 at 19:53

0 Answers0