Here's a simple way to create your own add-in. Basically, an add-in has two broad steps.
So the first step to create an add-in would be to create your sub-procedure or routine that you want to run by using your add-in.
Second, you create controls / menus for the user so that they can simply click on a button to execute your macro.
Here's the basic code that covers these two steps
Code:
Sub Auto_Open()
Dim objCB As CommandBarButton
Call Auto_Close
Set objCB = Application.CommandBars("Ply").Controls.Add(Type:=msoControlButton)
With objCB
.Style = msoButtonIconAndCaption
.Caption = "&Add Sheet..."
.OnAction = "AddSheet"
.FaceId = 245
.Visible = True
End With
End Sub
Sub Auto_Close()
On Error Resume Next
Application.CommandBars("Ply").Controls("&Add Sheet...").Delete
Err.Clear: On Error GoTo 0
End Sub
Private Sub AddSheet()
Dim sht As Object
Set sht = ActiveSheet
With Application
.EnableEvents = 0
.ScreenUpdating = 0
End With
ActiveWorkbook.Worksheets.Add After:=ActiveSheet
sht.Activate
With Application
.EnableEvents = 1
.ScreenUpdating = 1
End With
End Sub
Bookmarks