View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Ken Warthen[_2_] Ken Warthen[_2_] is offline
external usenet poster
 
Posts: 70
Default Test for comment in cell

I have a routine that search for a given number in a range on worksheet. If
the given number if found I want to test for a comment associated with the
found cell. My code is returning true for any given number so something is
wrong, but I can't seem to figure it out. If anyone has experience with
testing for a comment, I'd be very appreciative. My code follows.

TIA,
Ken

Public Function fCellHasComment(lngStoreNumber As Long) As Boolean
On Error GoTo PROC_ERROR
Dim Cell As Range

With ThisWorkbook.Worksheets("Price Groups")
For Each Cell In Range("PriceGroupsStoreNumbers")
If Cell.Value = lngStoreNumber Then
If Cells(Cell.Row, Cell.Column).Comment.Text = "" Then
fCellHasComment = False
Else
fCellHasComment = True
End If
End If
Next Cell
End With


PROC_EXIT:
Exit Function
PROC_ERROR:
Call ShowError("modUtilities", "fCellHasComment", Err.Number,
Err.Description, Err.Source)
Resume PROC_EXIT
End Function