Sub NewSheet()
Dim UnlockCode As String, Naam As String
UnlockCode = "Aanpassen"
Naam:
Naam = Replace(InputBox("Geef NAAM nieuwe tabblad in: "), " ", "_")
If Naam = vbNullString Then
Exit Sub
ElseIf IsNumeric(Left(Naam, 1)) Then MsgBox "Ongeldige Naam ingegeven, 1ste karakter is nummeriek !": GoTo Naam:
End If
For sh = 1 To Worksheets.Count
If UCase(Naam) = UCase(Sheets(sh).Name) Then MsgBox "Deze naam komt al voor!": GoTo Naam:
Next sh
For j = 1 To 6
If InStr(Naam, Choose(j, "\", "/", "?", "*", "[", "]")) <> 0 Then MsgBox "U heeft een ongeldig karakter opgegeven \ / ? * [ ]": GoTo Naam:
Next
Application.ScreenUpdating = False
On Error Resume Next
On Error GoTo 0
ThisWorkbook.VBProject.VBComponents("Module1").CodeModule _
.AddFromString Replace(Replace(Replace("Sub #()*Application.GoTo Sheets(@#@).Range(@E13@)*End Sub", "#", Naam), "@", Chr(34)), "*", vbCr)
With ActiveSheet
.Unprotect Password:=UnlockCode
.Shapes("Button 1").Copy
.[A19].Select
.Paste
End With
With Selection
.ShapeRange.IncrementTop 34 * [Info!B1].Value
.Characters.Text = Naam
.OnAction = Naam
End With
ActiveSheet.Protect Password:=UnlockCode
Sheets("Uitsnijden").Copy Before:=Sheets("Uitsnijden")
Sheets("Uitsnijden (2)").Name = Naam
With Sheets(Naam)
.Visible = True
.[E13].Value = Naam
End With
[Info!B1].Value = [Info!B1].Value + 1
Application.ScreenUpdating = True
End Sub