7

I'm having real difficulties adding a comment to a cell.

I'm calling the following sub

Sub ValidationError(row As Long, column As Integer, ErrorLine As String)

Tabelle1.Cells(row, column).Interior.Color = vbYellow
Tabelle1.Cells(row, column).AddComment ErrorLine

End Sub

But I always get a 1004 error, saying "Application or object error" (this is translated, original message: "Anwendungs- oder objektdefinierter Fehler")

The sub is called using

Call ValidationError(8, 9, "Text string")

What am I doing wrong?

Best

1
  • hello can you please try this: Tabelle1.Cells(row, column).AddComment Text:=ErrorLine Commented Feb 13, 2015 at 7:55

1 Answer 1

13

Your code should work if the target cell does not contain a comment. You can change the procedure to clear existing comments first:

Sub ValidationError(row As Long, column As Integer, ErrorLine As String)

Tabelle1.Cells(row, column).Interior.Color = vbYellow
Tabelle1.Cells(row, column).ClearComments
Tabelle1.Cells(row, column).AddComment ErrorLine

End Sub
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.