If-Verschachtelung und On Error GoTo
03.07.2019 09:43:01
Leon.DerProf
weiß jemand, warum ich bei folgendem Befehl immer auf AblaufenGo2 springe?
Dim festNr As Long
Dim findenNr As Range
Dim start As Long
Dim findenstart As Range
Dim ende As Long
Dim findenende As Range
Dim fte As String
Dim Maßnahme As String
Dim festNr2 As Long
Dim sh As Shape
Dim rng As Excel.Range
Dim shp As Excel.Shape
festNr = ActiveCell.Offset(0, -6).Value
start = ActiveCell.Offset(0, -5).Value
ende = ActiveCell.Offset(0, -4).Value
fte = ActiveCell.Offset(0, -3).Value
Maßnahme = ActiveCell.Offset(0, -2).Value
festNr2 = ActiveCell.Offset(0, 3).Value
On Error GoTo AblaufenGo2
If Worksheets("Balkenplan").Shapes("ZeitTeil " & festNr2 & " | Nr. " & festNr) Is Nothing Then
On Error GoTo AblaufenGo
If Not Worksheets("Balkenplan").Shapes("Zeit " & festNr) Is Nothing Then
Application.ScreenUpdating = False
With Worksheets(2)
.Activate
.Cells(findenNr.Row, findenstart.Column).Select
Set sh = ActiveSheet.Shapes.AddShape(msoShapeChevron, ActiveCell.Left, ActiveCell.Top + _
ActiveCell.Height / 1.5, ActiveCell.Height, ActiveCell.Height / 3)
sh.Select
With Selection
.ShapeRange.ShapeStyle = msoShapeStylePreset26
.ShapeRange.Line.Weight = 1
.Placement = xlMoveAndSize
.name = "ZeitTeil " & festNr2 & " | Nr. " & festNr
End With
Set rng = Worksheets("Balkenplan").Range(Cells(findenNr.Row, findenstart.Column).Address)
Set shp = Worksheets("Balkenplan").Shapes("ZeitTeil " & festNr2 & " | Nr. " & festNr)
shp.Left = rng.Left
shp.Width = Range(findenstart.Address, findenende.Address).Width
End With
End If
End If
Exit Sub
AblaufenGo:
MsgBox "Erstellen Sie eine Aufgabe!", vbInformation, "Information"
Exit Sub
AblaufenGo2:
MsgBox "Diese Aufgabe existiert bereits!"
Exit Sub
Beste Grüße
Leon