Trying to turn button code into a function so it works with multiple buttons

Thank you both very much for taking the time to look at my code and respond!