Place a character in a cell

L

Lisa38

I am trying to write a formula that will cause an asterisk to appear in one
cell if another cell has a comment in it. How do I do this?

Thanks,
 
D

Dave Peterson

You could use a user defined function:

Option Explicit
Function CellHasComment(rng As Range) As Boolean
Application.Volatile
CellHasComment = Not (CBool(rng.Cells(1).Comment Is Nothing))
End Function


This function may be one calculation behind. It won't update if you add a
comment. But should reflect the right answer once excel recalcs.

If you're new to macros:

Debra Dalgleish has some notes how to implement macros here:
http://www.contextures.com/xlvba01.html

David McRitchie has an intro to macros:
http://www.mvps.org/dmcritchie/excel/getstarted.htm

Ron de Bruin's intro to macros:
http://www.rondebruin.nl/code.htm

(General, Regular and Standard modules all describe the same thing.)

========
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:
=cellhascomment(a1)
Where A1 contains a comment (or not).

Then if that works, try:
=IF(CellHasComment(A1),"*","")
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top