Kompilierungsfehler
08.08.2005 08:51:11
Josef
Ich erhalte beim Eintrag in den Zeilen 12 und 13 einen Kompilierungsfehler:
erwartet:Anweisungsende
und das Wort Lotus Notes oder Binf neu (2) wird markiert.
Was mache ich hier bitte falsch.
Danke
Josef
Sub WB_Code_via_VBA_Kapitel()
Const WS As String = "Kapitel"
'Dim WB As Workbook
Dim VBC As Object
Dim LineNr
'Set WB = Workbooks.Add
With ActiveWorkbook.VBProject.VBComponents(WS).CodeModule
LineNr = .CreateEventProc("Change", "Worksheet")
.InsertLines LineNr + 1, "Dim r As Long, wsB As Worksheet, wsC As Worksheet"
.InsertLines LineNr + 2, "If Target.Column = 7 And Target.Row > 1 Then"
.InsertLines LineNr + 3, "If Target.Count = 1 Then"
.InsertLines LineNr + 4, "Set wsB = Sheets("Lotus Notes")"
.InsertLines LineNr + 5, "Set wsC = Sheets("Binf neu (2)")"
.InsertLines LineNr + 6, "r = Target.Row - 1"
.InsertLines LineNr + 7, "Application.EnableEvents = False"
.InsertLines LineNr + 8, "On Error GoTo ERRH"
.InsertLines LineNr + 9, "Range(Cells(r, 1), Cells(r, 6)).Copy Range(Cells(r + 1, 1), Cells(r + 1, 6))"
.InsertLines LineNr + 10, "wsB.Range(wsB.Cells(r, 1), wsB.Cells(r, 6)).Copy wsB.Range(wsB.Cells(r + 1, 1), wsB.Cells(r + 1, 6))"
.InsertLines LineNr + 11, "wsC.Range(wsC.Cells(r, 1), wsC.Cells(r, 9)).Copy wsC.Range(wsC.Cells(r + 1, 1), wsC.Cells(r + 1, 9))"
.InsertLines LineNr + 12, "Range(Cells(r, 8), Cells(r, 9)).Copy Range(Cells(r + 1, 8), Cells(r + 1, 9))"
.InsertLines LineNr + 13, "wsB.Range(wsB.Cells(r, 7), wsB.Cells(r, 12)).Copy wsB.Range(wsB.Cells(r + 1, 7), wsB.Cells(r + 1, 12))"
.InsertLines LineNr + 14, "wsC.Range(wsC.Cells(r, 22), wsC.Cells(r, 26)).Copy wsC.Range(wsC.Cells(r + 1, 22), wsC.Cells(r + 1, 26))"
.InsertLines LineNr + 15, "Set wsB = Nothing"
.InsertLines LineNr + 16, "Set wsC = Nothing"
.InsertLines LineNr + 17, "End If"
.InsertLines LineNr + 18, "End If"
.InsertLines LineNr + 19, "ERRH:"
.InsertLines LineNr + 20, "Application.EnableEvents = True"
End With
End Sub