ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Last Comment (https://www.excelbanter.com/excel-programming/351658-last-comment.html)

Gary''s Student

Last Comment
 
How do I set a cell equal to the text in the last comment in a column?
--
Gary's Student

Jim Cone

Last Comment
 
Hello Gary,
This seems to work...
'----------------------------
Sub TestForComments()
Dim rngColumn As Excel.Range
Dim objComment As Excel.Comment
Dim lngRow As Long
Dim strText As String
Set rngColumn = ActiveSheet.Columns(2).Cells

For Each objComment In ActiveSheet.Comments
If Not Application.Intersect(objComment.Parent, rngColumn) Is Nothing Then
If objComment.Parent.Row lngRow Then
lngRow = objComment.Parent.Row
strText = objComment.Text
End If
End If
Next
Range("F1").Value = strText
End Sub
'-------------------------------------
Regards,
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware



"Gary''s Student"
wrote in message
...
How do I set a cell equal to the text in the last comment in a column?
--
Gary's Student

Gary''s Student

Last Comment
 
Thank you (yet again)
--
Gary's Student


"Jim Cone" wrote:

Hello Gary,
This seems to work...
'----------------------------
Sub TestForComments()
Dim rngColumn As Excel.Range
Dim objComment As Excel.Comment
Dim lngRow As Long
Dim strText As String
Set rngColumn = ActiveSheet.Columns(2).Cells

For Each objComment In ActiveSheet.Comments
If Not Application.Intersect(objComment.Parent, rngColumn) Is Nothing Then
If objComment.Parent.Row lngRow Then
lngRow = objComment.Parent.Row
strText = objComment.Text
End If
End If
Next
Range("F1").Value = strText
End Sub
'-------------------------------------
Regards,
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware



"Gary''s Student"
wrote in message
...
How do I set a cell equal to the text in the last comment in a column?
--
Gary's Student



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

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