Um Rundungsdifferenzen auszuschließen will ich den Kommentar einer Zelle mit deren Inhalt vergleichen, jedoch erhalte ich bei folgenden Code die Fehlermeldung:
LZF 91 - Objektvariable oder With-Blockvariable nicht festgelegt.
Ich vermute mal es liegt daran dass ich Kommentar und Wert direkt vergleichen möchte.
Code:
Sub rundungsdifferenz()
Dim irowmax_2 As Integer
Dim icolmax_2 As Integer
Dim icol_2 As Integer
Dim irow_2 As Integer
Dim kommentar_2 As String
Dim zellwert$
Dim kommentar_kto$
Dim icol_kto As Integer
irowmax_2 = ThisWorkbook.Worksheets("IASEKDGT").UsedRange.SpecialCells(xlCellTypeLastCell).Row
icol_kto = 3
kommentar_kto = Sheets("Hilfstabelle").Cells(1, 1).Text
icolmax_2 = 16
For irow_2 = 2 To irowmax_2
For icol_2 = 1 To icolmax_2
If Sheets("IASEKDGT").Cells(irow_2, icol_2).Comment.Select = Sheets("IASEKDGT").Cells(irow_2, _
icol_2).Text Then
Sheets("IASEKDGT").Cells(irow_2, icol_kto).Interior.ColorIndex = 35
If Sheets("IASEKDGT").Cells(irow_2, icol_kto).Comment Is Nothing Then
Sheets("IASEKDGT").Cells(irow_2, icol_kto).AddComment kommentar_kto
Else
Sheets("IASEKDGT").Cells(irow_2, icol_kto).ClearComments
Sheets("IASEKDGT").Cells(irow_2, icol_kto).AddComment kommentar_kto
End If
End If
Next icol_2
Next irow_2
End Sub
Wenn ich das ganz mit folgendem Code versuche erhalte ich die Fehlermeldung:
LZF 1004 - Anwendungs- oder objektorientierter Fehler.
Code Variante 2:
Sub rundungsdifferenz()
Dim irowmax_2 As Integer
Dim icolmax_2 As Integer
Dim icol_2 As Integer
Dim irow_2 As Integer
Dim kommentar_2 As String
Dim zellwert$
Dim kommentar_kto$
Dim icol_kto As Integer
irowmax_2 = ThisWorkbook.Worksheets("IASEKDGT").UsedRange.SpecialCells(xlCellTypeLastCell).Row
icol_kto = 3
kommentar_kto = Sheets("Hilfstabelle").Cells(1, 1).Text
icolmax_2 = 16
kommentar_2 = Sheets("IASEKDGT").Cells(irow_2, icol_2).Comment.Select
zellwert = Sheets("IASEKDGT").Cells(irow_2, icol_2).Text
For irow_2 = 2 To irowmax_2
For icol_2 = 1 To icolmax_2
If kommentar_2 = zellwert Then
Sheets("IASEKDGT").Cells(irow_2, icol_kto).Interior.ColorIndex = 35
If Sheets("IASEKDGT").Cells(irow_2, icol_kto).Comment Is Nothing Then
Sheets("IASEKDGT").Cells(irow_2, icol_kto).AddComment kommentar_kto
Else
Sheets("IASEKDGT").Cells(irow_2, icol_kto).ClearComments
Sheets("IASEKDGT").Cells(irow_2, icol_kto).AddComment kommentar_kto
End If
End If
Next icol_2
Next irow_2
End Sub
Ich weiß der Code ist sicherlich nicht besonders schön.
Vielen Dank
Grüße
Elise