Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel Finding out if a comment has been added 1

Status
Not open for further replies.

HebieBug

Programmer
Jan 8, 2001
354
JP
Excel puts these little yellow sticky notes which it attaches to a cell.
Am writting a lovley little application that brings all the data from excel which will be put into SQL.
Have almost finished with it except where I come across a comment (yellow note). I need to extract that infromation and put it into a variable.
Here is some code that I am playing around with
excel_sheet_TEST.Cells(2, 1).Comment.Text
This works perfectly if the comment exists.
How I would need it to work is
IF A_comment_Exists THEN
excel_sheet_TEST.Cells(2, 1).Comment.Text
end if

Does anyone know how I can check if the comment exists

It's a mind baffeler for me
 
If you play around with this, you should get the idea:
Code:
Option Explicit
Sub test()
Dim r As Range
Dim c As Comment
  For Each r In ActiveSheet.UsedRange
    Set c = r.Comment
    If Not c Is Nothing Then
      MsgBox r.Address(0, 0) & " Comment: " & c.Text
    End If
  Next r
  Set c = Nothing
End Sub
 
Have been working on it some more. Excellent code Zathras.
I could not figure ou how to get it from a range to a straight active cell. Until this morning.
Here it is

If excel_sheet_TEST.Cells(2, 1).NoteText <> &quot;&quot; Then
MsgBox excel_sheet_TEST.Cells(2, 1).Comment.Text
End If

Can't believe it..
check out Uncle Bill's site for more info
 
Thanks HebieBug, for teaching me about yet another Excel property I'd never used before (.notetext)!
Rob
[flowerface]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top