#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 73
Default comments

I want to go through a column of data and find which cells have "comments"

so when it hit's the cell that has a comment i just want it to let me know

so when i write my code i can write something like

if cell(x,y) has a comment then
z = true
end if

so
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default comments

Maybe...

if cells(x,y).comment is nothing then
'no comment
else
z = true
end if

dstiefe wrote:

I want to go through a column of data and find which cells have "comments"

so when it hit's the cell that has a comment i just want it to let me know

so when i write my code i can write something like

if cell(x,y) has a comment then
z = true
end if

so


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 73
Default comments

question...

what is the opposite of "nothing"

so if you wanted to put

if cells(x,y).comment is ??????? then
z = true
else
no comment
end if

"Dave Peterson" wrote:

Maybe...

if cells(x,y).comment is nothing then
'no comment
else
z = true
end if

dstiefe wrote:

I want to go through a column of data and find which cells have "comments"

so when it hit's the cell that has a comment i just want it to let me know

so when i write my code i can write something like

if cell(x,y) has a comment then
z = true
end if

so


--

Dave Peterson

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default comments

The opposite of True is Not True, so...

If Not Cells(x, y).Comment Is Nothing Then
z = True
Else
' No comment
End If

Out of curiosity, what are you doing? I ask because it almost sounds like
the purpose of your code is to find and then do something with the comments
in a column and not do anything else. If that is the case, you can iterate
the Comments collection and work directly with the ones you want. For
example, this macro...

Sub FindComments()
Dim C As Comment
If ActiveSheet.Comments.Count 0 Then
For Each C In ActiveSheet.Comments
If C.Parent.Column = 1 Then
Debug.Print C.Parent.Address(0, 0) & " has the comment: " & C.Text
End If
Next
End If
End Sub

will print out the address of the cells in Column A and what the comment is
that it contains. Obviously, this is a very simplistic; however, you can do
whatever you need to in place of the Debug.Print statement I used in my
example. Inside the inner If-Then block, C will hold a reference to a
Comment object which you can use in your code. I'm not sure what you are
trying to do (assuming I'm right and that you only are interested in doing
something only with the comments or the cells that contain the comments),
but if you give us more details, we would be happy to help.

--
Rick (MVP - Excel)


"dstiefe" wrote in message
...
question...

what is the opposite of "nothing"

so if you wanted to put

if cells(x,y).comment is ??????? then
z = true
else
no comment
end if

"Dave Peterson" wrote:

Maybe...

if cells(x,y).comment is nothing then
'no comment
else
z = true
end if

dstiefe wrote:

I want to go through a column of data and find which cells have
"comments"

so when it hit's the cell that has a comment i just want it to let me
know

so when i write my code i can write something like

if cell(x,y) has a comment then
z = true
end if

so


--

Dave Peterson


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default comments

VBA doesn't support Something.

You can either change "if" portion or use the Then and Else portion.

I like the added ()'s:

if not (cells(x,y) is nothing) then
'it has a comment
else
'it has no comment
end if



dstiefe wrote:

question...

what is the opposite of "nothing"

so if you wanted to put

if cells(x,y).comment is ??????? then
z = true
else
no comment
end if

"Dave Peterson" wrote:

Maybe...

if cells(x,y).comment is nothing then
'no comment
else
z = true
end if

dstiefe wrote:

I want to go through a column of data and find which cells have "comments"

so when it hit's the cell that has a comment i just want it to let me know

so when i write my code i can write something like

if cell(x,y) has a comment then
z = true
end if

so


--

Dave Peterson


--

Dave Peterson


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
excel 2000 how to format the comments font all comments Delquestion Excel Discussion (Misc queries) 1 October 8th 09 02:19 PM
Comments Fiona Excel Discussion (Misc queries) 2 July 4th 08 09:31 AM
comments Richard[_8_] Excel Discussion (Misc queries) 0 June 29th 08 07:04 PM
in excel useing comments how do you add clip art to comments? dhouse New Users to Excel 2 July 18th 07 08:14 AM
Comments Help Dave 2005 Excel Worksheet Functions 0 August 29th 05 06:52 PM


All times are GMT +1. The time now is 11:45 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"