Hallo Burns,
bist du dir sicher, dass die Suchbefehle auch entsprechende Zellen finden, die sie aktivieren können. Sonnst kommt es zu diesem Fehler. Du kannst ihn aber z.B. mit einer sinnvollen On Error-Bedingung abfangen.
Gruß
Holger
Burns schrieb am 20.03.2009 12:08:59:
Hallo ich habe ein Problem mit folgendem Makro. Wenn ich in die Tabelle1 wechsle und dort nach dem Inhalt der Variable "nummer" suche kommt folgender Fehler "Objektvariable oder With-Blockvariable nicht festgelegt". Kann mir da jemand weiterhelfen.
[Code]
Private Sub CommandButton3_Click()
Dim i As Integer
Dim nummer As String
Dim nummerlinks, nummerrechts As String
Dim abnahme, hm1 As String
ActiveSheet.Range("a3").Activate
Do While ActiveCell.Value > 0
If ActiveCell.Offset(0, 8).Value = "" And ActiveCell.Offset(0, 7).Value = "V20_VFF" Then
nummer = ActiveCell.Offset(0, 2).Value
nummerlinks = Left(nummer, 3)
nummerrechts = Right(nummer, 3)
nummer = nummerlinks & "-" & nummerrechts
Sheets("Tabelle1").Select
Cells.Find(What:=nummer, After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate
Cells.Find(What:="Abnahme von bis", After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate
abnahme = ActiveCell.Value
For i = 1 To 100
hm1 = Right(abnahme, i)
hm1 = Left(hm1, 1)
If hm1 = "s" Then
i = i + 1
hm1 = Right(abnahme, i)
hm1 = Left(hm1, 1)
If hm1 = "i" Then
i = i + 1
hm1 = Right(abnahme, i)
hm1 = Left(hm1, 1)
If hm1 = "b" Then
Exit For
End If
End If
Else: hm1 = ""
End If
Next i
abnahme = Right(abnahme, i - 4)
abnahme = Left(abnahme, 10)
Sheets("Tabelle2").Activate
ActiveCell.Offset(0, 11).Value = abnahme
ActiveCell.Offset(0, 11).EntireColumn.AutoFit
End If
ActiveCell.Offset(1, 0).Activate
Loop
End Sub
[/code]
Im vorraus schon mal Danke
Gruß
Burns |