hey !
I try to copy some macro codes into a new worksheet. This new worksheet is added and names after NewSheetName. I found a code, but this one was used to enter code in "tabelle1", which seems not to be a worksheet.
I tried to change "tabelle1" and insert the NewSheetName, but got the error "Subscript out of range"
Do u have an idea what I have to change the code?
Thanks!
I try to copy some macro codes into a new worksheet. This new worksheet is added and names after NewSheetName. I found a code, but this one was used to enter code in "tabelle1", which seems not to be a worksheet.
HTML:
http://vba1.de/vba/020makrorein.php
I tried to change "tabelle1" and insert the NewSheetName, but got the error "Subscript out of range"
Code:
Sub AddNewSheet
Dim NewSheetName as string
NewSheetName = Worksheets("blank").Range("B1").Value
´( .... )
Dim x As Integer
With ThisWorkbook.VBProject.VBComponents(NewSheetName).CodeModule
x = .CreateEventProc("SelectionChange", "Worksheet")
.InsertLines x + 1, "'Test"
End With
End Sub
Do u have an idea what I have to change the code?
Thanks!