How to put comments within formulas

Has anyone played around with putting comments or labels within formulas? What I mean is to have a formula with several arguments, with some of them individually labeled with text.


If the arguments are cells, this often happens automatically if you have Use header cell names as references on, but in my situation, the source arguments only exist in the formula. And comments are nice, but they attach to the entire cell, not individual arguments.


What I'd like to do is a formula like this:


= 25 + 50


where I can tell that 25 is the number from May and 50 is the number from June.


Something like this would be ideal:


= 25["May"] + 50["June"]


but since there is not support for that in Numbers, the only way to do something like this is to fake it.


I have found three solutions:


=REPLACE("May",1,99,"25") + REPLACE("June",1,99,"50")


=IFERROR( NOT("May"), 25) + IFERROR( NOT("June"), 50)


=IF(TRUE,25,"May") + IF(TRUE,50,"June")


I prefer the last one, but none are particularly elegant. I wish I could find a single formula that takes just two arguments, the string and the value, and always outputs the value. The challenge is most formulas take cells or boolean expressions, not strings.


Can anyone else think of a more efficient way to do this?


.

MacBook Pro (17-inch Late 2011), Mac OS X (10.7.4)

Posted on May 15, 2012 6:38 AM

Reply
11 replies

May 15, 2012 9:57 AM in response to Jerrold Green1

I never suggested that Numbers should add a feature to do this, or that Excel could do it. And as I explicitly said in my first post, I am not looking for solutions based around comments or header names, so let's not continue those discussions.


What I'm looking for are clever workarounds to provide inline commenting within formulas.


I found three ways to do so.


Can anyone find any others?

May 16, 2012 7:20 AM in response to Wayne Contello

As I said earlier, temporary tables are not practical or efficient, and I don't think this should be a feature.


I wasn't asking for well known, documented ways of solving the problem. Sometimes a good hack is faster and more efficient.


I just wanted to demonstrate how to manipulate Numbers into provide inline comments, and I was trying to get folks to think out of the box (well, in this case, within the cell's box).

May 15, 2012 8:06 AM in response to Jerrold Green1

Thanks, Jerry. I use comments in some cases but they aren't efficient in this situation because it is too much duplicated effort. It is one more place you have to go, you have to repeat your data entry, and you have to remember to keep it in sync when you change your formula.


Inline comments are much faster to type and to notice when reviewing and editing the formula.

May 15, 2012 9:43 AM in response to John F. Whitehead

John F. Whitehead wrote:


Thanks, Jerry. I use comments in some cases but they aren't efficient in this situation because it is too much duplicated effort. It is one more place you have to go, you have to repeat your data entry, and you have to remember to keep it in sync when you change your formula.


Inline comments are much faster to type and to notice when reviewing and editing the formula.

John,


That may be true, but the likelyhood of anything like that coming to a little app like Numbers is pretty remote. I don't think even Excel has that "feature". My preference is and always has been to make the code as self-documenting as possible. Numbers makes this easy with the ability to name small tables within a sheet and, for those who like it, to reference cells by Header names.


Copy/Paste will get your expression from the cell to the comment box in a couple of seconds.


Jerry

May 15, 2012 4:41 PM in response to John F. Whitehead

There are additional ways to do it (i.e., other formulas you can use) but all of them are kludges, just like the ones you used.


I am wondering what you trying to do exactly. A formula that takes variables usually refers to other cells that contain those variables; you don't typically type the new numbers directly into the formula each month, you type them into other cells and the formula references those cells. When done this way, the header names should work for you to "comment" your formula.

May 16, 2012 3:55 AM in response to John F. Whitehead

Wayne, as I said twice previously, I am aware of using header cell names but that doesn't work since these values aren't referencing other cells. I only used May & June as an example.


Badunit, in my situation these formulas don't reference other cells or variables. I do that plenty often, but in this case these are many transient numbers that creating separate cells with headers would be too time consuming.


For example, I might be counting values for something I'm inventorying. An actual formula might look like:


= 10 + 25 + 22 + 5 + 15 + 5 + 2 + 160 + 5 + 5


That is the value for one location on one date; I have 12 locations, 100 dates with about 6 types of information to track, meaning 12 tables of 600 cells each already, 7200 cells total. I'm not going to also create 7200 separate tables with tens of thousands of cells to track each of those numbers separately; it's not that important and a big waste of time to do so.


But I do sometimes want to comment on discrepancies or unusual numbers. On the above, I might have written it as:


= 10 + 25 + 22 + 5 + 15 + 5 + 2 + IF(TRUE,160,"includes extra carryover from last week") + 5 + 5


Yes, comments are designed to do that. But they don't always make things easier: they are an extra place to enter information and look for it, and some people might miss it. The next day when someone updates the formula with changed values, they may not notice the comment, or they have to click back & forth to see what parts of the comment refer to what. If there are several commented values and they need to delete or change a certain one, it is easy at a glance to do so correctly.


I'm not saying there aren't other ways of doing this. I'm just saying in some limited circumstances inline comments could be time savers when you have a lot of data entry, and I was wondering if others had thought about solving the problem.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

How to put comments within formulas

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.