VBA Reading comment out of Cell (syntax?)

cboshdave

Board Regular
Joined
Jan 12, 2011
Messages
68
I have seen several examples of how to read cell comments. I am doing it slightly different and I guess my syntax is wrong??
My line that tries to set sComment = Cells(r,c).Comment.Text does not ever grab the Comments from the cell. I'm hoping this is dumb format/syntax problem.

Code:
        DIM sComment as Comment
        ...
        On Error Resume Next
        sComment = Cells(iRow, iCol).Comment.Text  'Even if there is a comment, this line does not see it??
        If Not sComment Is Nothing Then
            If sComment.Text = "#LAST_ROW" Then
                bStop = True 'Defined globally so main method can use.
                Exit Do
            End If
        End If
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
I have seen several examples of how to read cell comments. I am doing it slightly different and I guess my syntax is wrong??
My line that tries to set sComment = Cells(r,c).Comment.Text does not ever grab the Comments from the cell. I'm hoping this is dumb format/syntax problem.

Code:
        [B][COLOR="#FF0000"]DIM sComment as Comment[/COLOR][/B]
        ...
        On Error Resume Next
        sComment = Cells(iRow, iCol).Comment.Text  'Even if there is a comment, this line does not see it??
        If Not sComment Is Nothing Then
            If sComment.Text = "#LAST_ROW" Then
                bStop = True 'Defined globally so main method can use.
                Exit Do
            End If
        End If

Dim your sComment variable as a String data type, not a Comment data type... the Text value returned from a Comment property is a String value.
 
Upvote 0

Forum statistics

Threads
1,214,929
Messages
6,122,317
Members
449,081
Latest member
tanurai

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top