[Solved] Increment/decrement feature for cells

Discuss the spreadsheet application
Locked
pecohen
Posts: 9
Joined: Sat Sep 29, 2012 4:06 am

[Solved] Increment/decrement feature for cells

Post by pecohen »

I'd like to suggest what should be an easy feature enhancement for calc. On a right click, two options should be to increment/decrement the current entry (when it is data, not a formula). Even better would be to assign quick-keys for these features.

It seems very often when I edit data in a spreadsheet it is only to increase a data value by 1 or perhaps 2. I used to have an editor that did this (a variant of VI) and I found it quite useful.
Last edited by MrProgrammer on Fri Jul 17, 2020 3:56 pm, edited 2 times in total.
Reason: Changed subject, was: Feature Suggestion; Tagged ✓ [Solved]
OpenOffice 4.1.10 on Windows 10
User avatar
Zizi64
Volunteer
Posts: 11362
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Feature Suggestion

Post by Zizi64 »

Do you mean the integers to increase/decrase by ±1? Or do you want to modify every type of numeric values?

You can customize the floating menu in the LibreOffice. (The Apache OpenOffice has not such feature.) And you can assign your own macros to the floating menu. Just write a macro that will read the value from the selected cell, increase/decrase the value, then put it back into the cell.
Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
pecohen
Posts: 9
Joined: Sat Sep 29, 2012 4:06 am

Re: Feature Suggestion

Post by pecohen »

What I had in mind was integers or integer-like data (so, including dates and the like). Actually in the editor I used to use it would increment character data (changing 'A' to 'B' for example) and I did find that quite useful, sometimes even for entering a special character. I don't think that would work well in Calc, however. I've not tried using macro's in OO for a long time; when I did I found them so slow as to not be very useful. Hardware has speeded up a lot since then however.
OpenOffice 4.1.10 on Windows 10
User avatar
Lupp
Volunteer
Posts: 3553
Joined: Sat May 31, 2014 7:05 pm
Location: München, Germany

Re: Feature Suggestion

Post by Lupp »

You find a solution based on usercode here:

https://ask.libreoffice.org/en/question ... -by-a-day/
There is also an example file containing the code, explanations, and a preconfigured user toolbar named 'specialDocToolbar'. I cannot tell you in what place it will be displayed for you. Just look around. It will show 'IncDec'

The macro tries to modify its action depending on the modifier keys that were pressed in addition to the click into the sensitive area (there is only one) of the toolbar. However, AOO (even the recent version 4.1.7) doesn't pass the 'Alt' key to the called macro, and I have no idea how your old version will do.
Of course you can rework the macros a bit and use two areas in the toolbar to get the additional functionality I implemented with the help of 'Alt'. The triple modification 'Shift'+'Ctrl'+'Alt' is a bit unhandy, anyway.

Any not too old LibreOffice will support the full range of the feature.

Well, I will also attach the demo here. It was made with LibO V6.4.4.
Attachments
ask233471_IncrementDecrementByShortcut_2.ods
(24.59 KiB) Downloaded 196 times
On Windows 10: LibreOffice 24.2 (new numbering) and older versions, PortableOpenOffice 4.1.7 and older, StarOffice 5.2
---
Lupp from München
User avatar
Zizi64
Volunteer
Posts: 11362
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Increment/decrement feature for cells

Post by Zizi64 »

____________________________________
OpenOffice 3.4.1 on Windows XP
Please update your signature in this forum and/or upgrade the Office suite too.
I suggest you to use the LibreOffice.
Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
User avatar
Zizi64
Volunteer
Posts: 11362
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Increment/decrement feature for cells

Post by Zizi64 »

Any not too old LibreOffice will support the full range of the feature.
All of the features work for me in my LO 6.2.8 and in my LO 6.1.6 portable too. (on Windows10 x64 Prof and with Hungarian Windows keyboard)

But the ALT-Inc/Dec, CTRL-ALT-Inc/Dec not work in my portable AOO 4.1.7 nor in my LO 4.4.7 portable...
Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Increment/decrement feature for cells

Post by Villeroy »

Works out of the box if you would use an input form connected to a database. Spreadsheets were never meant to be anything like a database.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
User avatar
Lupp
Volunteer
Posts: 3553
Joined: Sat May 31, 2014 7:05 pm
Location: München, Germany

Re: Increment/decrement feature for cells

Post by Lupp »

It's true. I never liked databases, and I'm no longer a user. Therefore I never post about them beyond a general advice, not to stick to spreadsheets where a typical database task is in view. This doesn't mean that I always was completely ignorant about the DB field. I even spent some time to study what there was in about 1992+odd.

There are (unfortunately) many cases where databases are the only sufficiently reliable means - though they, of course, also have their shortcomings and their bugs. I suppose there's a reason for what specialists create new database engines and SQL flavors all the time while cashiers call for help now and then and need the market manager to get their wonderful DB running correctly again.

When I still not was retired I also had sufficient opportunities to get nearly mad with DB complications where I mandatorily had to work at the same time with three (+1 + another related program) "professional" DB applications that should co-operate but didn't sufficiently. OK surely everything got perfect since, and I simply didn't notice it.

When I recently stumbled at a script by one of my former students, on the other hand, Calc (in combination with a CAS) really helped to get things clear. I didn't want to sell pants and sweeties.

There may also be a few tasks where a user has a real choice between db and sheets as his means - and the world is filled with zillions of problems where neiter a db nor sheets actually help.

In this forum you (Villeroy) once used the phrase "If you only have a hammer, everything looks like a nail." There's some truth in it. And it also holds if the hammer is a database.

Why so many words?
I simply feel a bit annoyed now and then by the way some contributors implicitly ascribe incompetence to others.
On Windows 10: LibreOffice 24.2 (new numbering) and older versions, PortableOpenOffice 4.1.7 and older, StarOffice 5.2
---
Lupp from München
User avatar
MrProgrammer
Moderator
Posts: 4908
Joined: Fri Jun 04, 2010 7:57 pm
Location: Wisconsin, USA

Re: Increment/decrement feature for cells

Post by MrProgrammer »

pecohen wrote:I'd like to suggest what should be an easy feature enhancement for calc.
This is a user-to-user forum. No one here can change Calc.
pecohen wrote:… two options should be to increment/decrement the current entry (when it is data, not a formula).
You can record macros to increment and decrement. To decrement:
Tools → Macros → Record
• Edit → Copy
• Edit → Paste (this highlights the current cell so the selection does not change in the following step)
• Type -1 (minus one) and press Enter
• Edit → Paste Special → Selection:Numbers,DateTime Options:None Operations:Add ShiftCells:Don't → OK
Stop recording then assign a name to your macro. You only need to do this recording once. It takes less than a minute.

To increment, record a second macro and type 1 instead of -1 in the third step. The same two macros can be used to increment/decrement, numbers, currency, dates, etc. They will execute in a fraction of a second.
pecohen wrote:Even better would be to assign quick-keys for these features.
Tools → Customize can be used to map a keyboard shortcut or toolbar button to this macro. OpenOffice does not provide a simple method to attach the macro to the context (right-click) menu.
[Tutorial] Binding a macro: Shortcut key, menu or toolbar
Customizing OpenOffice.org
pecohen wrote:It seems very often when I edit data in a spreadsheet it is only to increase a data value by 1 or perhaps 2.
You can create separate macros, perhaps for a toolbar, to increment/decrement by 2. You could also have on your Increment/Decrement toolbar buttons for percentages (increment/decrement by .01 instead of 1), various fractions of your choosing (.5, .25, .333333333333333, …), hours (4.16666666666667E-2), minutes (6.94444444444444E-4), and seconds (1.15740740740741E-5). The following recording toggles between TRUE and FALSE.
• Edit → Copy
• Edit → Paste
• Type 1 and press Enter
• Edit → Paste Special → Selection:Numbers Options:None Operations:Subtract ShiftCells:Don't → OK

All of this is done with standard Calc fatures. You don't need to learn any programing. You do need to know how to use Calc's standard user interface.

If this solved your problem please go to your first post use the Edit button and add [Solved] to the start of the title. You can select the green checkmark icon at the same time.

[Tutorial] Ten concepts that every Calc user should know
Mr. Programmer
AOO 4.1.7 Build 9800, MacOS 13.6.3, iMac Intel.   The locale for any menus or Calc formulas in my posts is English (USA).
Locked