ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Help with reading comments. (https://www.excelbanter.com/excel-programming/296808-help-reading-comments.html)

Al Bundy

Help with reading comments.
 
Try adding "On Error Resume Next" to your code that's
getting runtime error 91. If you are using a loop you
need to declare an array variable to store multiple
comments. Instead of assigning the comments to an array I
would just assign them to another cell. See example below.

For i = 1 To ActiveSheet.UsedRange.Rows.Count
If Cells(i, "A").Comment.Text < "" Then Cells(i, "B") =
Cells(i, "A").Comment.Text
Next

Hope this helps... Al

-----Original Message-----
Hi, I need some help with comments. Specifically, I'm

trying to write a macro that needs to test to see if a
cell has a comment, and if so, store the contents of that
comment in a string variable. I think I can figure the
rest out on my own, but every time I try something like:

myComment = Range(myCurrentCell).Comment.Text

I get an runtime error 91. It's very annoying. I've

noticed that

myComment = Range("A1").Comment.Text

works just fine, it just doesn't like the variable in the

range. MyCurrentCell is in a For/Next Loop and get's its'
value from the line:

myCurrentCell = c.Address([False], [False])

I've used similar things in all sorts of other macros,

so... I'm stumped.

Thanks for your help.
.



All times are GMT +1. The time now is 10:10 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com