Live-Forum - Die aktuellen Beiträge
Anzeige
Anzeige
HERBERS
Excel-Forum (Archiv)
20+ Jahre Excel-Kompetenz: Von Anwendern, für Anwender

Forumthread: Inhalt Kommentar mit Zellinhalt vergleichen

Inhalt Kommentar mit Zellinhalt vergleichen
22.10.2008 16:06:38
Himmelsbach
Hallo zusammen,
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

Anzeige

3
Beiträge zum Forumthread
Beiträge zu diesem Forumthread

Betreff
Datum
Anwender
Anzeige
AW: Inhalt Kommentar mit Zellinhalt vergleichen
22.10.2008 16:32:00
Rudi
Hallo,
sind denn auch in allen Zellen Kommentare vorhanden? Sonst gibt es den Fehler, wenn man versucht auf einen nicht vorh. Kommentar zuzugreifen.
Gruß
Rudi
AW: Inhalt Kommentar mit Zellinhalt vergleichen
22.10.2008 16:42:00
Himmelsbach
nein es sind nicht in allen Feldern Kommentare vorhanden
AW: Inhalt Kommentar mit Zellinhalt vergleichen
22.10.2008 16:54:53
Rudi
Hallo,
ungetestet:

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
Dim cmtC As Comment
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
Set cmtC = Sheets("IASEKDGT").Cells(iRow_2, iCol_2).Comment
If Not cmtC Is Nothing Then
If cmtC.Text = 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
End If
Next iCol_2
Next iRow_2
End Sub


Gruß
Rudi

Anzeige
;

Forumthreads zu verwandten Themen

Anzeige
Entdecke relevante Threads

Schau dir verwandte Threads basierend auf dem aktuellen Thema an

Alle relevanten Threads mit Inhaltsvorschau entdecken
Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige
Anzeige
Entdecke mehr
Finde genau, was du suchst

Die erweiterte Suchfunktion hilft dir, gezielt die besten Antworten zu finden

Suche nach den besten Antworten
Unsere beliebtesten Threads

Entdecke unsere meistgeklickten Beiträge in der Google Suche

Top 100 Threads jetzt ansehen
Anzeige