Hallo mit folgendem Code-Fragment frahe ich die Labels eine UF ab welche zuvor dynamisch erzeugt wurden. Naturlich gibt es eine Fahlermeldung wenn ein Objrkt nicht zu finden ist. wie kann ich diese umgehen und den fehlerhaften Wert i einfacch weiter hochzählen lassen. ich hab schon ne menge probiert, bspw. mit Resume Next und goto, aber nichts hilft immer wieder der Laufzeitfehler. Ich bitte um einen Hinweis
Herzlichen Dank!
For i = 2 To x 'MsgBox FGT.Name
If Charge.Controls("Label" & (i)).BackColor = &H8000000D Then
Set OptXPR = Sheets(TgtTAB).Columns(OptCH.Column).Find(what:=CDbl(Mid(Charge.Controls("Label" & (i)).Caption, 10, 8)), lookat:=xlWhole, LookIn:=xlValues)
p = i
' MsgBox FGT.Name & " das gewählte Feld wurde gewechselt"
For o = OptXPR.Row To Sheets(TgtTAB).Cells(Rows.Count, 4).End(xlUp).Row
If Sheets(TgtTAB).Cells(o, 4).Value = CDbl(Mid(Charge.Controls("Label" & (i)).Caption, 10, 8)) Then
l = o
If Sheets(TgtTAB).Cells(o, 5) = 1 Then
FGT.Label101 = Format(CDbl(Charge.Label101) - CDbl(Sheets(TgtTAB).Cells(o, 9)), "#,0.00 ")
Charge.Label102 = Format(CDbl(Charge.Label102) - CDbl(Sheets(TgtTAB).Cells(o, 9)), "#,0.00 ")
End If
If Sheets(TgtTAB).Cells(o, 5) = "0" Then
Charge.Label101 = Format(CDbl(Charge.Label101) - Sheets(TgtTAB).Cells(o, 9), "#,0.00 ")
End If
Charge.Label105 = Format(Charge.Label105 - (Sheets(TgtTAB).Cells(o, 10)), "#,0.00 ")
Charge.Label103 = "./. " & Format(((CDbl(Charge.Label101) - CDbl(Charge.Label105)) / CDbl(Charge.Label102)), "#,0.00 %")
Charge.Label104 = "./. " & Format(CDbl(Charge.Label101) - CDbl(Charge.Label105), "#,0.00 ")
End If
Charge.Controls("Label" & (i)).BackColor = &H8000000F
Next o
If CDbl(Mid(Charge.Controls("Label" & (i)).Caption, 10, 8)) = CDbl(Mid(FGT.Caption, 10, 8)) Then
Exit Sub
Else
End If
End If
Next i