OpenOffice Calc SUM of TRUNC number cells, with rows that include text cells - openoffice-calc

RE: Apache OpenOffice 4.1.7, AOO417m1(Build:9800) - Rev. 46059c9192, 2019-09-03 12:04.
I need to sum non-integer entries across a range of cells, but without including the decimal values (complicated by some cells being text). I started with ROUNDDOWN, then TRUNC, then FLOOR. I'm driving myself nuts trying to find a clean code (or even an arbitrarily extensible ugly code) for what would be the following:
=SUMIF(ISTEXT(R7:CL7);0;TRUNC(R7:CL7))
The above doesn't work, of course, since TRUNC() doesn't apply to ranges, but it conveys what I'm trying to do in a nutshell -- some of the cells contain text, which SUM() ignores (luckily), but they flummox TRUNC, so I needed to handle the text problem.
I started with ISNUMBER, just to get the ball rolling; ISTEXT has fewer characters, but it's not worth fixing that right now.
FLOOR was equally disappointing for ranges:
=SUM(FLOOR(R7:T7;1))
I tried variations of =SUM(IF(... and searches for ROUNDDOWN range (and variations on that) and such pseudocode as "IFTEXT" and "SUMTRUNC" (and variations on that). I found info on ROUNDDOWN(SUM(... and so forth, but not "SUM(ROUNDDOWN(..." or any equivalent.
In my delirium, I got silly and even tried:
=SUMIF(ISTEXT(S7:U7);0;AND(TRUNC(S7);TRUNC(T7);TRUNC(U7)))
To be clear: {2.9→2 + 2.9→2 + 2.9→2 = 6} ≠ {2.9+2.9+2.9 = 8.7→8}. I'm looking for a 6, not an 8 (I'd joke about sixes and sevens, but I'm way past pumpkin o'clock and 2.428571 takes up too much space).
My current test-kludge is:
=SUM(IF(ISNUMBER(R7);ROUNDDOWN(R7);0);IF(ISNUMBER(S7);ROUNDDOWN(S7);0);IF(ISNUMBER(T7);ROUNDDOWN(T7);0); ... ;IF(ISNUMBER(AX7);ROUNDDOWN(AX7);0))
It ends at AX7 only because of the char count. I hope to SUM the whole row in a single sweep, but that ain't gonna cut it. I could do it in large chunks in multiple cells, and then add those cells up, but oy gevalt.
Since it's already ugly anyway, I could use the following to save a few characters, but this would only mean being able to extend the range maybe 6 further cells (not much point in that):
=IF(ISTEXT(R7);0;TRUNC(R7))+IF(ISTEXT(S7);0;TRUNC(S7))+IF(ISTEXT(S7);0;TRUNC(S7))
I'm seriously considering simply going down a bunch of rows (to below my data cells) and entering the following, then copying the cell and pasting it to a complementary range, and telling the SUM cells to just sum up their respectively shadowed rows (instead of the data rows that they sit in):
=IF(ISTEXT(R7);0;TRUNC(R7))
Sorry for the rambling; I need sleep. This started as a need, then multiple failed attempts became a grudge match of principle and obstinacy, and now I'm just plugging away at it out of blind habit developed over the past 2-3 days (hopefully I won't forget what the purpose was).
In summary...: ++?????++ Out of Cheese Error +++DIVIDE BY CUCUMBER.
I'm comfortable enough with macros, though it's been ~7 years (and that was in Excel). Thanks in advance, even if the answer is that I'm stuck with one of these! 🙂
EDIT: I don't see a way to attach a .csv here (though I could open the .csv with Notepad, and copy-and-paste the contents if that would help anyone), so here's a set of pics:

Related

How to automatically feed a cell value from a range of values, based on its matching condition with other cell value

I'm making a time-spending tracker based on the work I do every hour of the day.
Now, suppose I have 28 types of work listed in my tracker (which I also have to increase from time to time), and I have about 8 significance values that I have decided to relate to these 28 types of work, predefined.
I want that, as soon as I enter a type of work in cell 1 - I want the adjacent cell 2 to get automatically populated with a significance value (from a range of 8 values) that is pre-definitely set by me.
Every time I input a new or old occurrence of a type of work, the adjacent cell should automatically get matched with its relevant significance value & automatically get populated in real-time.
I know how to do it using IF, IFS, and IF_OR conditions, but I feel that based on the ever-expanding types of work & significance values, the above formulas will be very big, complicated, and repetitive in the future. I feel there's a more efficient way to achieve it. Also, I don't want it to be selected from a drop-down list.
Guys, please help me out with the most efficient way to handle this. TUIA :)
Also, I've added a snapshot and a sample sheet describing the problem.
Sample sheet
XLOOKUP() may work. Try-
=XLOOKUP(D2,A2:A,B2:B)
Or FILTER() function like-
=FILTER(B2:B,A2:A=D2)
You can use this formula for a whole column:
=INDEX(IFERROR(VLOOKUP(C14:C,A2:B9,2,0)))
Adapt the ranges to your actual tables in order to include in the second argument all the potential values and their significances
This is the formula, that worked for me (for anybody's reference):
I created another reference sheet, stating the types of work & their significance. From that sheet, I'm using either vlookup, filter, xlookup.Using gforms for inputting my data.
=ARRAYFORMULA(IFS(ROW(D:D)=1,"Significance",A:A="","",TRUE,VLOOKUP(D:D,Reference!$A:$B,2,0)))

Excel Alternative to nested IF

I have a couple of rather large nested if functions in my spreadsheet. It sure would be nice to have an alternative method. Problem is I'm using a wildcard (*) in my lookup because the source text has slight variations (date for example).
For example, if my list of data contains:
VENMO PAYMENT 220828 1022093447487 BRENDA HOSPY
VENMO PAYMENT 220813 1031323447487 BRENDA HOSPY
I want these to show in an adjacent column of cells as just Venmo
Currently my if function in that second column of cells is:
=IF(COUNTIF($F10,"*APPLE.COM/BILL*"),"AP",
IF(COUNTIF($F10,"IIA VOYA*"),"VOYA",
IF(COUNTIF($F10,"VENMO PAYMENT*"),"Venmo",
IF(COUNTIF($F10,etc...
This works fine but quickly gets unruly as more things get added.
I've spent a great deal of time searching for functions and processes that would make this easier, or at least more compact, but I can't find a way with typical functions like vlookup or index/match.
If I've explained this in a comprehensible fashion perhaps you've seen or experienced a similar situation and could offer a suggestion. It would be appreciated!
I'm not opposed to using a programming function.
I've looked at, and for, various Excel functions or combinations with no luck on my own or online.
I have created a structure as below
Formula present in B2 is as below
=IFERROR(INDEX($F$2:$F$9,MIN(IF(COUNTIF(A2,"*"&$E$2:$E$9&"*")>0,ROW($E$2:$E$9),9999999)-1)),"---")
Enter it as an Array Formula using Ctrl+Shift+Enter
It will search all the strings present in column E in A2 when found will return all the row numbers of column E where there is a match, i have then used min to get the first one, and if not found it will return 9999999, and as the data is starting from row 2 i have added -1 to make it equal to the data index. after that i have called the index to search value present at that index in column F. and at the end used the if error function to show --- where no match was found and 999999 was returned.

Is there a way to override Font.Position increments to make them smaller (to less than.5 pt)? With VBA or otherwise?

I'm writing a VBA macro in Word(365) which loops through a selection character by character and randomizes font position (raise/lower) and spacing*. I know what you're thinking, and yes, this makes the final .docx file size much larger than the original.
*Context: Why? I'm a hobbyist book designer/poet/editor trying to mimic the warmth/analog/organic feel (and subtle inherent flaws) of hand-set letterpress type.
So, here's the deal: The code works. That's not the problem.
The problem is that Word's Font.Position increments are hard-coded at .5 pt, so when my macro calculates the random position, Word rounds it to the nearest .5 pt. That is just too large for what I need with my small fonts (usually 12 pt). I may be on a wild goose chase, but is there any way to override these increments, via VBA (ideally) or otherwise (C++?), to make them smaller for a more subtle effect?
Note: The Font.Spacing increments are .05 pt, so that's not a problem, just Font.Position.
I was also monkeying around with the page size, thinking that I could just make a huge page & font size (ie: 1000%), to make up for the too-large .5 pt increments, and then scale it back down (to 10%) to its intended size in a PDF, but the limit on page size is a mere 22" which is not big enough to make much of a difference.
My next option is to translate the same macro into LibreOffice Writer. That program uses integer % increments instead of .5 pt increments, which would be about 4x more precise # 12 pt font (.12 pt increments). As such, Writer would out perform Word in this application until the font size is 50 pt or larger. I do not have much experience with LO Basic, and documentation/example code is much harder to come by. I know it's very similar to VBA and there's a lot of crossover. It might/might not be an easy project, I just haven't tried yet.
Anyway, I wanted to see if there was a way around the increments in Word first because I'd like to have this application within both Word and Writer.
Right now, I'm under the assumption that the increments are hard-coded into Word and there's nothing I can do about it.
Prove me wrong.
Thanks!
P.S. I know nothing about C++ and if everyone tells me that Word is a lost cause and I should just translate it to Writer I'll do that (I may anyway) and post my code for that later if I get stuck.
Completely nonsense. According to VBA Word reference, property Font.Position is Long. This property sets the vertical alignment of a selected text above (or below) the line. In UI: Font-Advanced-Character Spacing-Position.
Manually you can set this property with 0.5 rounding.
Macro recording also shows command "Selection.Font.Position = 0.5"
No way you can assign the property Font.Position with a fraction using macro, because it's Long.
I would like to have a macro shifting text above or below the line, but it is possible only to shift by step of 1.0 (or 0.5 via UI). Hope, there is a workaround... (at least for 0.5. Could you show you code example with 0.5 shift?)
Updated I have found a workaround. According to the old WordBasic reference - the minimum step for Position is 0.5 pt.
To get the value with 0.5 fraction (of the selected text. Font.Position returns Long with no fraction)
MsgBox Dialogs(wdDialogFormatFont).Position
To set the value with 0.5 fraction (to the selected text), you must use old-style WordBasic
WordBasic.FormatFont Position:="-0.5"
Hope, this helps somebody...
More about old WordBasic: https://learn.microsoft.com/en-us/office/vba/word/concepts/customizing-word/conceptual-differences-between-wordbasic-and-visual-basic
https://learn.microsoft.com/en-us/office/vba/word/concepts/customizing-word/built-in-dialog-box-argument-lists-word

Apply a function to a range of cells in a spreadsheet

The answers in topics with similar titles haven't given me much of a resolution to my particular problem, but possibly I am not asking the right question. It might help knowing I'm an absolute noob when it comes to spreadsheets, so finding my way around is next to nil.
Currently I can set a basic function in the first cell A1 =ROW()
Simple right? Well now here comes the complication. If I click on the bottom right of the cell and start dragging I can then apply that very same function to a whole range of cells. Let's say I apply it from A1:A10. Every cell within this group now has the same function.
Hooray! We did it, right? I applied a function to a range of cells each with their own output. But wait, if I then go back to the original cell and change its formula none of the other cells change with it. GRRRRR!!!!
There are a couple of fixes I've come up with but don't necessarily know how to implement. The first is to have every cell link back to the original cell and reference its function. This would be useful if I wanted to randomly scatter dependent cells about the document. The other would be much more useful in an orderly group where you know the exact dimensions by specifying in the original cell the size of the array you want to apply the function to.
With that said, let me hear your thoughts.
The closest I've come to an answer is to use FORMULA() which returns the formula used by a cell as text. Unfortunately all answers on evaluating the text resort to scripting. How strange! I thought something like this would be common. Might as well get to scripting.
Hold on, I may have spoke too soon. An array can be made with =MUNIT(), but it's only square. Drats!
Ok... I'm hoping the zebra stripes will eventually become its own answer unless someone else beats me to it. So a simple array can be made with ={1,2;3,4} where commas separate values by column and semicolons for values by row except to generate it you have to press Control+Shift+Enter (because reasons?). I'm thinking now that I'll need to have functions that can generate lists of values based on a single function for each row, and pray that it'll work. So, back to looking. (Wow this is taking forever)
The way I was hypothesizing can't even generate a 1x1, e.g., ={ROW()} returns Err:512 which is a formula overflow.
Alright, in summary so far I've narrowed down the two options,
1) link every cell to the original formula
2) populate an array with a single formula
each with their own incomplete answer,
a) use FORMULA() to return the formula of a cell as text
b) create a hypothetical array like so ={LIST_OF_VALUES()}
These both require a strange form of the nonexistent EVALUATE() function to 'function' correctly. Isn't that fun?
Google Sheets handles case b by allowing ={ROW()}Control+Shift+Enter to generate =ArrayFormula({ROW()}). Working with the general case of any sized array being filled with a single function doesn't exist in the world of spreadsheets it seems. That's very saddening because I can't think of a much better tool for what I want to do. Copy paste it is until I need to use macros.
Depending on your specific use case, creating a user-defined function may help:
use the Basic IDE to create your function;
apply it to any cells on any sheet;
modifying the Basic code will affect all cells where the function is used.
I've elaborated the steps in an answer on superuser.
Sure, you could write some complex code to update functions, but wouldn't the easy way be just to drag it to the same range of cells the same way you did before? It should properly overwrite the existing code in there, and if it doesn't, you can just as easily delete the outdated code and drag the new code in.
Probably the best approach is to simply drag the amended formula over the range of cells (as advised by OldBunny2800). This is less error prone and easier to maintain than a custom macro.
Another option would be to use an array function. Then you only have to edit the function once, and the same edit will be automatically applied to the whole range of cells in that array function.

c++ using text files to make graphs

So I want to use large text files with baby names, and the frequency of the name being used each year since 1880. I have a text file for each year with names and frequencies. I need to read in the text files and have the user input a name and a year that they want to see the frequency of (which is not the problem I have, I can do that). When the user inputs the name and year, though, I want to have a line graph show up that shows the frequency of the name as the y-axis and the years as the x-axis. I am using myro which allows the use of graphics and what not, but where should I start? I'm very lost on how to do this.
When I was doing something similar (but in ASCII) to that before, I quickly realized there were two options:
A)The graph will not be well looking, and actually fit only SCREEN_WIDTH years,
B)The graph will show only the most interesting years
C)The graph will not fit on one screen.
D)You will somehow sum up values not fitting to one screen.
Personally I choose option C), which can be solved as follows:
Each column is one year (or one year range). Set the row of that column, at the same height as the frequency value equal to "COLORED".
The number of rows has the same problem, as we can only fit SCREEN_HEIGHT elements there. As long however, as the shape of the line was shown, to me it was acceptable, so sacrifice of precision was worth it.