I have an excel file where the first sheet is an index of all the sheets in the workbook.
I need a macro that adds three buttons to every sheet except for the first sheet (the index)
I will need to run this macro again and again as new sheets are added. Rather than searching for the new sheets and adding the buttons the macro would just run on every sheet again so it will need to delete any buttons previously added and add the buttons again so that it is not adding buttons on top of buttons for the sheets that were already in the workbook.
This is what I have so far but I'm not sure how to skip the first sheet and how to delete all buttons before adding the buttons again.
I need a macro that adds three buttons to every sheet except for the first sheet (the index)
I will need to run this macro again and again as new sheets are added. Rather than searching for the new sheets and adding the buttons the macro would just run on every sheet again so it will need to delete any buttons previously added and add the buttons again so that it is not adding buttons on top of buttons for the sheets that were already in the workbook.
This is what I have so far but I'm not sure how to skip the first sheet and how to delete all buttons before adding the buttons again.
Code:
Sub NextSheet()
ActiveSheet.Next.Select
End Sub
Sub PrevSheet()
ActiveSheet.Previous.Select
End Sub
Sub firstsheet()
ActiveWindow.ScrollWorkbookTabs Position:=xlFirst
Sheets("All Specs").Select
End Sub
Sub addButton()
Dim wks As Worksheet
For Each wks In ThisWorkbook.Worksheets
wks.Activate
ActiveSheet.Buttons.Add(650, 18, 60, 25).Select
Selection.OnAction = "PrevSheet"
Selection.Caption = "Previous"
ActiveSheet.Buttons.Add(730, 18, 60, 25).Select
Selection.OnAction = "NextSheet"
Selection.Caption = "Next"
ActiveSheet.Buttons.Add(810, 18, 60, 25).Select
Selection.OnAction = "firstsheet"
Selection.Caption = "To Index"
Next wks
End Sub