Adding a value in the comment field (little red triangle)?

B

Barb

Hi ,


I have cells that contain prices. I have a function to calculate
the sum of 5 cells. Is it possible to add this value in the comment field
(little red triangle in the corner of the fifth cell)?. Can I do it with VBA?

Thanks Jack
 
K

keeena

I assume you're expecting the comment field to be dynamic/volatile?
Pretty sure that's not possible; value in a comment field is just
static text.

You could write a VBA routine that can add up cells and put the value
into a new or existing comment. This routine would need to be run
every time you changed or added new data (if you wanted the values to
be up-to-date). Could attach it to an Event so that it always runs
when the worksheet is selected.
 
B

Barb

Hi Keeena,

Yes I just want to add the value that was calculated in VBA. That's
not Dynamic. how can I add the value of the variable that was calculated in
VBA in that comment field?

Thanks.
 
K

Keith R

Barb/Jack-
it isn't clear to me if you are asking for more comprehensive help (how do I
add up the numbers in VBA in the first place) but with regards to just
adding it in a static comment, it is something like (air code):

Sheet1.Range("E4").Comment.Text Text:="The sum is " & cStr(MyTotal)

Where MyTotal is the variable where you've added up your values.

If you need to do this for multiple rows, you'll need to use a loop to cycle
through the appropriate rows (will it be the same rows each time, or do you
need to be able to specify which rows?), add them up (which cells need to be
added?) and decide if there are any conditions in which a total was
calculated in a previous run of the macro and needs to be removed.

If you need more help, just post again and let us know how far you got.

Keith
 

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