Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 37
Default show Comment using INDEX

Hi there,

A B
1 Apple 44 (with red-arrow comment "fruit")
2 Pine 55
3 Apple 66
4 Orange 77

I've added comment "fruit" on cell B1
After I use INDEX function to locate B1, only the value in the cell shows
but NOT
the comments. Which means, only "44" shows.

How can I show the red-arrow comment "fruit" as well?

Thanks.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default show Comment using INDEX

The INDEX function can retrun the value of a cell. It cannot return the
associated comment in the cell or the format of that cell.
--
Gary''s Student - gsnu200765


"Lucy" wrote:

Hi there,

A B
1 Apple 44 (with red-arrow comment "fruit")
2 Pine 55
3 Apple 66
4 Orange 77

I've added comment "fruit" on cell B1
After I use INDEX function to locate B1, only the value in the cell shows
but NOT
the comments. Which means, only "44" shows.

How can I show the red-arrow comment "fruit" as well?

Thanks.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 37
Default show Comment using INDEX

I'm looking for creating a user defined function. Will macros help?

"Gary''s Student" wrote:

The INDEX function can retrun the value of a cell. It cannot return the
associated comment in the cell or the format of that cell.
--
Gary''s Student - gsnu200765


"Lucy" wrote:

Hi there,

A B
1 Apple 44 (with red-arrow comment "fruit")
2 Pine 55
3 Apple 66
4 Orange 77

I've added comment "fruit" on cell B1
After I use INDEX function to locate B1, only the value in the cell shows
but NOT
the comments. Which means, only "44" shows.

How can I show the red-arrow comment "fruit" as well?

Thanks.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,836
Default show Comment using INDEX

There is a comprehensive list of comments-related stuff he
http://www.contextures.com/xlcomments01.html#All


Regards,
Ryan--

--
RyGuy


"Lucy" wrote:

I'm looking for creating a user defined function. Will macros help?

"Gary''s Student" wrote:

The INDEX function can retrun the value of a cell. It cannot return the
associated comment in the cell or the format of that cell.
--
Gary''s Student - gsnu200765


"Lucy" wrote:

Hi there,

A B
1 Apple 44 (with red-arrow comment "fruit")
2 Pine 55
3 Apple 66
4 Orange 77

I've added comment "fruit" on cell B1
After I use INDEX function to locate B1, only the value in the cell shows
but NOT
the comments. Which means, only "44" shows.

How can I show the red-arrow comment "fruit" as well?

Thanks.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default show Comment using INDEX

Let's assume that by using some combination of MATCH / INDEX / etc. we can
get the Address of the cell. So then some cell, say Z100 displays B1 as a
result of the worksheet formula.

=INDIRECT(Z100) will then display the Value of B1
=coment(Z100) will then display the comment in B1.

The UDF is:

Function coment(s As String) As String
coment = ""
If Range(s).Comment Is Nothing Then Exit Function
coment = Range(s).Comment.Text
End Function
--
Gary''s Student - gsnu200765


"Lucy" wrote:

I'm looking for creating a user defined function. Will macros help?

"Gary''s Student" wrote:

The INDEX function can retrun the value of a cell. It cannot return the
associated comment in the cell or the format of that cell.
--
Gary''s Student - gsnu200765


"Lucy" wrote:

Hi there,

A B
1 Apple 44 (with red-arrow comment "fruit")
2 Pine 55
3 Apple 66
4 Orange 77

I've added comment "fruit" on cell B1
After I use INDEX function to locate B1, only the value in the cell shows
but NOT
the comments. Which means, only "44" shows.

How can I show the red-arrow comment "fruit" as well?

Thanks.



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 37
Default show Comment using INDEX

Thanks Gary, but this UDF shows an error message & not working.
Btw, is this UDF returns the comment as "text in cell" or "comment"?
Because I hope it can return to destination cell as "comment" with the text
inside the cell.

If I use this UDF in cell C1 = coment (B1)
it will look exactly same as B1 -- 44 (with red-arrow comment "fruit")

"Gary''s Student" wrote:

Let's assume that by using some combination of MATCH / INDEX / etc. we can
get the Address of the cell. So then some cell, say Z100 displays B1 as a
result of the worksheet formula.

=INDIRECT(Z100) will then display the Value of B1
=coment(Z100) will then display the comment in B1.

The UDF is:

Function coment(s As String) As String
coment = ""
If Range(s).Comment Is Nothing Then Exit Function
coment = Range(s).Comment.Text
End Function
--
Gary''s Student - gsnu200765


"Lucy" wrote:

I'm looking for creating a user defined function. Will macros help?

"Gary''s Student" wrote:

The INDEX function can retrun the value of a cell. It cannot return the
associated comment in the cell or the format of that cell.
--
Gary''s Student - gsnu200765


"Lucy" wrote:

Hi there,

A B
1 Apple 44 (with red-arrow comment "fruit")
2 Pine 55
3 Apple 66
4 Orange 77

I've added comment "fruit" on cell B1
After I use INDEX function to locate B1, only the value in the cell shows
but NOT
the comments. Which means, only "44" shows.

How can I show the red-arrow comment "fruit" as well?

Thanks.

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default show Comment using INDEX

My mistake. I was assuming that you didn't the have address, but were
getting it via some sort of lookup function. If you want to get the comment
in cell B1 directly, then put:

=coment(B1) in another cell and change the code to:

Function coment(r As Range) As String
coment = ""
If r.Comment Is Nothing Then Exit Function
coment = r.Comment.Text
End Function

REMEMBER: remove the old verison of the UDF before pasting in the new
version.
--
Gary''s Student - gsnu200765


"Lucy" wrote:

Thanks Gary, but this UDF shows an error message & not working.
Btw, is this UDF returns the comment as "text in cell" or "comment"?
Because I hope it can return to destination cell as "comment" with the text
inside the cell.

If I use this UDF in cell C1 = coment (B1)
it will look exactly same as B1 -- 44 (with red-arrow comment "fruit")

"Gary''s Student" wrote:

Let's assume that by using some combination of MATCH / INDEX / etc. we can
get the Address of the cell. So then some cell, say Z100 displays B1 as a
result of the worksheet formula.

=INDIRECT(Z100) will then display the Value of B1
=coment(Z100) will then display the comment in B1.

The UDF is:

Function coment(s As String) As String
coment = ""
If Range(s).Comment Is Nothing Then Exit Function
coment = Range(s).Comment.Text
End Function
--
Gary''s Student - gsnu200765


"Lucy" wrote:

I'm looking for creating a user defined function. Will macros help?

"Gary''s Student" wrote:

The INDEX function can retrun the value of a cell. It cannot return the
associated comment in the cell or the format of that cell.
--
Gary''s Student - gsnu200765


"Lucy" wrote:

Hi there,

A B
1 Apple 44 (with red-arrow comment "fruit")
2 Pine 55
3 Apple 66
4 Orange 77

I've added comment "fruit" on cell B1
After I use INDEX function to locate B1, only the value in the cell shows
but NOT
the comments. Which means, only "44" shows.

How can I show the red-arrow comment "fruit" as well?

Thanks.

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 37
Default show Comment using INDEX

Hi Gary,

This one works, thanks.

But I think I didn't explain myself clearly. (it's hard to explain here
without graph/picture, sorry!)
I do not want to show the comment in the cell. But I want to show it as a
"comment".

A B
1 Apple 44 (with red-arrow comment "fruit")
2 Pine 55
3 Apple 66
4 Orange 77

in cell C1, I put =INDEX(A1:B4,1,2)
so result of C1 will be "44"

Since cell B1 has a comment attached, I want to bring this comment to C1 as
well. The UDF you've provided will overwrite "44".
The ideal result I'm looking for is "44" still shows in C1 and there will be
red-arrow at the corner as a comment.

I have done similar VBA before with Vlookup but unable to modify the code to
work as INDEX.

Again, really appreciate your help!





"Gary''s Student" wrote:

My mistake. I was assuming that you didn't the have address, but were
getting it via some sort of lookup function. If you want to get the comment
in cell B1 directly, then put:

=coment(B1) in another cell and change the code to:

Function coment(r As Range) As String
coment = ""
If r.Comment Is Nothing Then Exit Function
coment = r.Comment.Text
End Function

REMEMBER: remove the old verison of the UDF before pasting in the new
version.
--
Gary''s Student - gsnu200765


"Lucy" wrote:

Thanks Gary, but this UDF shows an error message & not working.
Btw, is this UDF returns the comment as "text in cell" or "comment"?
Because I hope it can return to destination cell as "comment" with the text
inside the cell.

If I use this UDF in cell C1 = coment (B1)
it will look exactly same as B1 -- 44 (with red-arrow comment "fruit")

"Gary''s Student" wrote:

Let's assume that by using some combination of MATCH / INDEX / etc. we can
get the Address of the cell. So then some cell, say Z100 displays B1 as a
result of the worksheet formula.

=INDIRECT(Z100) will then display the Value of B1
=coment(Z100) will then display the comment in B1.

The UDF is:

Function coment(s As String) As String
coment = ""
If Range(s).Comment Is Nothing Then Exit Function
coment = Range(s).Comment.Text
End Function
--
Gary''s Student - gsnu200765


"Lucy" wrote:

I'm looking for creating a user defined function. Will macros help?

"Gary''s Student" wrote:

The INDEX function can retrun the value of a cell. It cannot return the
associated comment in the cell or the format of that cell.
--
Gary''s Student - gsnu200765


"Lucy" wrote:

Hi there,

A B
1 Apple 44 (with red-arrow comment "fruit")
2 Pine 55
3 Apple 66
4 Orange 77

I've added comment "fruit" on cell B1
After I use INDEX function to locate B1, only the value in the cell shows
but NOT
the comments. Which means, only "44" shows.

How can I show the red-arrow comment "fruit" as well?

Thanks.

  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default show Comment using INDEX

Maybe this will help you get started:

Option Explicit
'=index(array,row_num,column_num)
Function IndexComment(myRng As Range, _
Optional myRow As Long = 1, _
Optional myCol As Long = 1) As Variant

Dim res As Variant

Application.Volatile True

res = Application.Index(myRng, myRow, myCol)

IndexComment = res

With Application.Caller
If .Comment Is Nothing Then
'do nothing
Else
.Comment.Delete
End If

If myRng(myRow, myCol).Comment Is Nothing Then
'no comment, do nothing
Else
.AddComment Text:=myRng(myRow, myCol).Comment.Text
End If
End With

End Function

This kind of function could be one calculation behind. If the comment in the
table changes, then you'll want to force a recalculation before you believe the
results.

Application.volatile true
means that excel will recalculate each of these formulas each time excel
recalculates. You may notice a slowdown in your workbook.

If you remove this line, then the results in the cell will be ok, but the
comment may be wrong.

(The results in the cell should always be ok--it's the comment that's the
trouble.)

If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm

Short course:

Open your workbook.
Hit alt-f11 to get to the VBE (where macros/UDF's live)
hit ctrl-R to view the project explorer
Find your workbook.
should look like: VBAProject (yourfilename.xls)

right click on the project name
Insert, then Module
You should see the code window pop up on the right hand side

Paste the code in there.

Now go back to excel.
Into a test cell and type:
=indexcomment(a1:c20,3,2)


Lucy wrote:

Hi there,

A B
1 Apple 44 (with red-arrow comment "fruit")
2 Pine 55
3 Apple 66
4 Orange 77

I've added comment "fruit" on cell B1
After I use INDEX function to locate B1, only the value in the cell shows
but NOT
the comments. Which means, only "44" shows.

How can I show the red-arrow comment "fruit" as well?

Thanks.


--

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
HOW DO i SHOW SAME COMMENT TO TWO OR MORE CELLS IN EXCEL MASIH Excel Discussion (Misc queries) 5 February 17th 09 07:35 AM
What does Show Ink in Excel, Review Tab, comment, do? E. Duke 462 Excel Worksheet Functions 0 August 8th 08 04:31 PM
Show Comment when in the cell Manju Excel Worksheet Functions 5 February 5th 07 02:16 PM
How can I make the comment show in a different part of the screee DB Excel Discussion (Misc queries) 2 November 24th 06 04:22 AM
How can I edit a comment w/o first having to select Show Comment Mary Ann Excel Discussion (Misc queries) 1 August 26th 05 12:34 AM


All times are GMT +1. The time now is 07:23 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"