Excel Sheet Adding - Deleting With Userform

Excel VBA Add Sheet - Assigning Macro To Short-Cut Key



       We created a userform and added a listbox, combobox, buttons, textbox control into the userform.
With this userform, a new sheet can be added to the workbook, the sheet can be deleted and can be navigated between sheets of the workbook .     
        If   key in keyboard is pressed on the any sheet, the userform opens. Because ,we assigned a macro that it provides userform is opened for excel assing macro to key key.
       Sheets of the workbook are listed on the combobox and listbox. We will use this listbox to add and delete worksheets.
With combobox can be navigated between sheets of the workbook. If selected any sheet from combobox ,that sheet's tab is activated .
The following codes provides assigning the macro to excel add sheet key :
Sub Auto_Open()
Application.OnKey "{F9}", "Show"
End Sub
 Sub Show()
    UserForm1.Show
End Sub

The created codes is following to list worksheets name on listbox and combobox :
...
Dim sayfa As Integer
    For sayfa = 1 To Sheets.Count
        ListBox1.AddItem Sheets(sayfa).Name
        ComboBox1.AddItem Sheets(sayfa).Name
    Next sayfa
....


excel vba add sheet

1 comment: