ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   comments (https://www.excelbanter.com/excel-programming/420871-comments.html)

dstiefe

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

Dave Peterson

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

dstiefe

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


Rick Rothstein

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



Dave Peterson

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


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

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