parentheses around a formula result - parentheses

How do I display the results of a formula -- e.g. "=(a1/b1)" which might return "45%" -- so that the result is surrounded by parens and appears as "(45%)"? Putting parens around the formula -- e.g. "(=(a1/b1))" -- doesn't work.

Do you mean in Excel? you can just set the format of the cell. how it should show the result.
Just right click on the Cell then format cells and then chose percentage on the left hand side. then change it to custome and put some parentheses arround the result. thats it ;)

Depends on the language you're using.
If =(a1/b1) works to give you "45%" then I would trying this: "(" + =(a1/b1) + ")"

I know this is an old thread but I thought it might be of interest for others as well.
To clarify the answer since it did not work for me when I tried it. In order to put the result from a function/formula within two parentheses in the same cell you need to use this function:
="("&(Cellfunction)&")".
In your case that would look like this:
="("&(A1/B1)&")".
If you have the same problem as the one asking the question, try copy/paste this funtion into a blank cell in a new sheet in Excel and type 1 into cell A1 and 2 into cell B1.
When using the funcion in the blank cell (for example C1) the result should be 0,5. This function also works for displaying parentheses around a returned answer. For example: Cell D252 displays the result from Cell C7 (C7 could have its own function/formula). That's how I used the function which looked like this:
="("&(C7)&")"
Hope this helps,
Best,
Felix, Business administration student in Sweden
I'm using Mac and Excel for Mac Home and Student 2011.

Related

Storing extra value for cells on iGrid 4

In one of my apps I'm still using the very old iGrid OCX version 4.
Upgradig to iGrid 6 is currently not an option for me.
I've desperately tried to find any way to store 2 extra strings in a Cell. They should not appear as a cell text.
The first thing I tried to do was assign a class to "CellValue" instead of "CellText", but it wouldn't be accepted.
Then I tried something something really dirty: I have simply added a hundred spaces and my 2 extra string, separated by a special char so that I could split them up later.
This however resulted in "..." being displayed on the cell texts. I could work around this by assigning textdraw flags to the cell, but when I hover over the cell, the entire string is shown again. I wanted to hide it.
Updating to version 6 or even iGrid.NET (where I could simply use CellTag or assign as class to a cell) is currently not an option for me.
Thank you for any help!
Aaaaahhhhh. :-D I got it:
I could simply (ab)use the "CellCtrlKey" property of a cell to store the additional strings.
Edit: Hmmm, I can set this value, but it gets ignored, meaning when I retrieve it, it is "" again.
I guess that is a value that can only be used when a cell is a checkbox cell.
Edit 2: I haven't found any way, so I now use a matrix / array of string, string that stores these extra values.
I'm also using iGrid.NET and iGrid6 in other projects, and in these versions, it's super easy, but as I explained, for this one project I can't upgrade.

Does anyone know why an object would miss a property?

We have a script that export our Indesign documents to HTML and one of the routine is to export tables. In this script we go throught each Tables->Rows->Cells and evaluate some of the properties (i.e. bottomEdgeStrokeType, topEdgeStrokeType, etc...) and transport them to HTML.
Now yesterday we had problem converting one particular document because some cells were missing the "bottomEdgeStrokeType" property entirely. I've discovered this by outputting the properties of each cells and compare the faulty ones with the others.
This line bellow was trowing the error: "Invalid object for this request.".
var cellType = cell["bottomEdgeStrokeType"];
Now, to fix this I've wrapped this around a try catch block to handle the case when it's not there, but now what is puzzling me is how on earth can Extendscript instantiate an object with missing properties?
Indesign version: CS5.5
A property is not only 'undefined' if it cannot exist at all (such as asking for the parent text frame for a character in overset text), but InDesign's Javascript engine also fails to return a reasonably accurate result for multiple values.
If you ask for "the" point size of a paragraph, where this paragraph contains multiple sizes, poor ID does not consider to return something like CONSTANT.Mixed, or the first value only, or (what I might have preferred) an array of the values; it returns undefined instead.
So how can a single table cell have multiple bottom strokes? If the cell underneath it is split into multiple cells, and one has a "top" stroke but the other has not.
It's difficult to recommend an adequate solution. You could first test if the current cell is "merged" (as far as InDesign's internal table model is concerned) with columnSpan; and if so, iterate over the number of columns spanned and test the next row's cells for their top stroke, which in theory should match the bottom stroke of the cell above. (I find myself wondering if this is always true. ID's table model is ... weird. It's not entirely like a HTML table, despite the functional overlaps.)
If columnSpan is greater than 1 and equal to the number of cells immediately below the current one, you could test if all of their "top" values are the same and if so use that value. (I never tested this so ID's table model may simply fail because a cell is merged, regardless of same-values or not.)
One could attempt to flag this cell's next row to output "top" strokes as well -- but alternating top and bottom strokes may not align nicely in CSS, side to side. Perhaps it's best to translate only the first top stroke value to "the" bottom stroke property for your current cell, and fix up manually where needed (how?) or, a reasonable action, hope that no-one will ever notice it.

Change VB6 cell properties on runtime?

I have a table with a foo number of rows and bar number of columns.
What i'd like is for the selected cell to really appear as being selected.
At the moment the leftmost cell gets a red text to mark it's being selected.
What i'd llike is for the lines at the top and bottom of the cell to get bigger to really show that the cell is selected.
I've looked at the following but without success.
grd.row = aRow
grd.col = aCol
' Therafter i try to change the following:
grd.CellBorderColor = 255 ' Original value does not change
grd.CellBorderStyle = 2 ' Original value does not change
EDIT:
I found out that previously named properties are read only.. What can i do?
Any tips and/or pointers in the right direction will be highly appreciated, thanks for reading.
This particular grid. Called vaSpread or fpSpread needs a specific line to execute.
For executing changes to grid style you need to call grid.action = 13 after you've written the visual changes to the grid.

How to retrieve a mean number into matlab GUI from cell string?

I am building a matlab GUI to retrieve an average PnL number from a 1047*1 double cell string called pnl_P1 into edit text window called (function Average_PnL_Pair_1_Callback(hObject, eventdata, handles)). What is the simplest or very simple way to do this?
Do you want mean(cellfun(#str2double, pnl_P1))?
If I understand your problem correctly I'd do the following.
Do not store numbers in cell string array, but if you must, use mean(cell2mat(pnl_P1)) to get the mean value. Create a value under handles so you can reach your pnl_P1 vector from anywhere.
handles.pnl_P1 = pnl_P1;
Make sure you always update your handles after each function in your GUI. It is strongly recommended.
% Update handles structure
guidata(hObject, handles);
Insert value into edit box:
set(handles.edit1,'String',mean(cell2mat(handles.pnl_P1)));
handles.edit1 is the tag handle for the edit box you want to update.
What is the tag for your edit box?
Simple: in guide right-click on your edit box, select properties inspector, scroll down to Tag. If it says edit1 then use handles.edit1 and so on.
If you are new to Matlab GUIs I recommend this. They have stopped updating it but it's a great learning source.
I hope this helps.

Win32 List-View Control SubItem padding for custom-drawn SubItems?

When using custom-draw (NM_CUSTOMDRAW) to draw the entire contents of a ListView SubItem (in Report/Details view), it would be nice to be able to apply the same left and right
padding in my custom paint method that is applied by the control itself for non-custom-drawn items.
Is there a way to programmatically retrieve this padding value? Is it
related to the width of a particular character (" " or "w" or something?) or
is it a fixed value (6px on left and 3px on right or something) or...?
EDIT: To clarify, I want to add the same padding to my NM_CUSTOMDRAWn SubItems that the control adds to items that it draws, and the metric that I'm looking for, for example, is the white space between the beginning of the 2nd column and the word "Siamese" in the following screenshot (Note: screenshot from MSDN added to help explain my question):
(source: microsoft.com)
Note that the word "Siamese" is aligned with the header item ("Breed"). I would like to be able to guarantee the same alignment for custom-drawn items.
use ListView Header message HDM_GETBITMAPMARGIN
see link text
ListView_GetSubItemRect (LVM_GETSUBITEMTECT)
http://msdn.microsoft.com/en-us/library/ms930172.aspx
Despite what the documentation says I suspect LVIR_LABEL returns just the returns the bounding rectangle of the item text, as per ListView_GetItemRect.
(This just kept niggling me as I though I had actually seen an answer somewhere when playing with NM_CUSTOMDRAW).
Edit After Comment 2:
I imagine you have seen NMLVCUSTOMDRAW which if you are willing to use Version 6.0. has rcText. I wouldn't since I use Win2K.
Given what you have found I would go back to the suggestion of using
ListView_GetItemRect to get LVIR_LABEL and compare that with LVIR_BOUNDS and use the difference.
the way for doing this is retrieving the format of the corresponding column with
ListView_GetColumn()
then check the retrieved myLVCOLUMN.mask
LVCOLUMN myLVCOLUMN;
myLVCOLUMN.mask=LVCF_FMT;
ListView_GetColumn(hwnd,nCol,&myLVCOLUMN);
then when we draw the corresponding label belonging to that column
if(myLVCOLUMN.fmt & LVCFMT_CENTER)
DrawText(x,x,x,x, DT_CENTER | DT_WORD_ELLIPSIS );
else if (myLVCOLUMN.fmt & LVCFMT_RIGHT)
DrawText(x,x,x,x, DT_RIGHT | DT_WORD_ELLIPSIS );
else
DrawText(x,x,x,x, DT_LEFT | DT_WORD_ELLIPSIS );
I would assume that GetSystemMetrics() is that you need to look at. I think that SM_CXEDGE and SM_CYEDGE are probably the values you want, but don't quote me on that. ;-)
Can only guess without seeing your output.
A few suggestions: If you are using the DrawTextEx function, have you have experimented with DT_INTERNAL et al?
Are you accidentally putting in a blank image/icon.
Does it look ok in classic screen mode? If so I would look at XP Theme functions to see if some thing is going on.
Late edit after first comment:
I wonder if the size of rectangle matches the space required for the LVN_ENDLABELEDIT edit box around the text so the text doesn't move (or for a focus rectangle)?
I guess you could compare the result of LVM_GETITEMRECT with LVIR_LABEL on the first column and use the difference as your left border.

Resources