sábado, 4 de agosto de 2018

Making a Cell that Increments Its Value +1 in LibreOffice

Today I learned how to increase the value of an active cell +1 by making a simple macro, thanks to oguillaume, who kindly offered this tutorial for OpenOffice.

This simple macro will add 1 to the value of the currently selected cell (known as the active cell).
This increment cell value macro is useful when associated with a keyboard shortcut for counting things rapidly.

Simply create a new Macro Sub :

  • In the menus, choose Macros > Organise Macros > OpenOffice Basic,
  • In the dialogue box unfold the following hierarchy "My Macros > Standard > Module 1"
  • Now that Module 1 is selected, click on button Edit
  • Copy and Paste the code below
  • Hit Save (Ctrl-S)    
Now all you have to do is Copy/Paste the code below in the editor that opened (the "ThisComponent... +1" is a SINGLE LINE).

Sub activecellplus1

ThisComponent.CurrentSelection.value = ThisComponent.CurrentSelection.value +1

End Sub


 Now to assign a keyboard shortcut:

  • In Menus, choose Tools > Customize ... ,
  • In Dialog, activate Tab called Keyboard
  • Look for an empty shortcut key in the list and select it
  • Now in the list called "Functions, Categories" scroll at the bottom of the list and look for '+ Open Office Macros'. (Click on the + to unfold) Now continue unfolding '+ User, + Standard, +Module1 '
  • Now in the list called Functions, you should see an entry called 'activecellplus1' . Select it
  • Now click the button called "Modify" and then OK at the bottom

Test it:

  • Choose an empty cell or put a value in a cell (e.g. 5).
  • Select the cell (click on it)
  • Now hit the shortcut you have created and see the value increment by 1
That was exactly what I needed!  Thanks!

1 comentario: