Hi Every one,
I am new in Macro coding and need your help on subjected topic.
How to write Macros code which add date/time in a cell when data is entered in another cell in the same row in LibreOffice calc [/b]
[Solved] Macro to add date/time when cell in row changed
[Solved] Macro to add date/time when cell in row changed
Last edited by Hagar Delest on Tue Oct 09, 2018 9:01 pm, edited 2 times in total.
Reason: tagged solved
Reason: tagged solved
LibreOffice Version: 5.1.6.2 on Ubuntu OS Version: :Linux 4.4
Re: Macro code to add date/time when cell in row changed
Welcome!
That's not as simple as you probably assume.
You will have to assign a handler to the sheet event 'Content changed'. That's not difficult at all in principle, but you need to be clear about your needs and your intentions first.
-1- What do you mean by "add" here? Should this read "insert?
-2- Data cannot only be entered into a cell via the keyboard one by one, but also by pasting and many at a time. What shall be done in such cases?
-3- What shall be done if data are edited / deleted?
-4- And ... (depending yon your answers to the above questions)
Whithout being precise concerning the mentioned questions any suggestions may result just in wasted time.
That's not as simple as you probably assume.
You will have to assign a handler to the sheet event 'Content changed'. That's not difficult at all in principle, but you need to be clear about your needs and your intentions first.
-1- What do you mean by "add" here? Should this read "insert?
-2- Data cannot only be entered into a cell via the keyboard one by one, but also by pasting and many at a time. What shall be done in such cases?
-3- What shall be done if data are edited / deleted?
-4- And ... (depending yon your answers to the above questions)
Whithout being precise concerning the mentioned questions any suggestions may result just in wasted time.
On Windows 10: LibreOffice 24.2 (new numbering) and older versions, PortableOpenOffice 4.1.7 and older, StarOffice 5.2
---
Lupp from München
---
Lupp from München
Re: Macro code to add date/time when cell in row changed
thanks for your prompt reply...
-1- What do you mean by "add" here? Should this read "insert?
ans:- i mean when ever data updated in the cell, the current date and time also update automatically.
-2- Data cannot only be entered into a cell via the keyboard one by one, but also by pasting and many at a time. What shall be done in such cases?
ans:- same rule should be apply any type of data entered date and time update automatically.
-3- What shall be done if data are edited / deleted?
ans:- only if data edited apply same rule for update date and time and if data deleted not required date and time update.
-1- What do you mean by "add" here? Should this read "insert?
ans:- i mean when ever data updated in the cell, the current date and time also update automatically.
-2- Data cannot only be entered into a cell via the keyboard one by one, but also by pasting and many at a time. What shall be done in such cases?
ans:- same rule should be apply any type of data entered date and time update automatically.
-3- What shall be done if data are edited / deleted?
ans:- only if data edited apply same rule for update date and time and if data deleted not required date and time update.
LibreOffice Version: 5.1.6.2 on Ubuntu OS Version: :Linux 4.4
Re: Macro code to add date/time when cell in row changed
Combined the informations and sample code snippets of these topics I just created this sample file below:
viewtopic.php?f=20&t=30516
viewtopic.php?f=20&t=85972
viewtopic.php?f=20&t=30516
viewtopic.php?f=20&t=85972
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.
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.
Re: Macro code to add date/time when cell in row changed
The nice and compact code contained in the example above has some flaws, unfortunately. In specific it will throw an error if you call 'Del' for a non-contiguous selection (multi-selection) becasue the selection not supports some used services in this case.
(The oEvent object would pass the same CellRanges -regard the plural- instead of a single range expected.)
Since I had some routines for similar tasks in my toolbox, I also created an example. See attachment.
To make an advanced multi-purose tool from what I supplied, the "process" parameter would need enhancement.
Criticism welcome!
(The oEvent object would pass the same CellRanges -regard the plural- instead of a single range expected.)
Since I had some routines for similar tasks in my toolbox, I also created an example. See attachment.
To make an advanced multi-purose tool from what I supplied, the "process" parameter would need enhancement.
Criticism welcome!
- Attachments
-
- aoo95416AutomaticTimeStampsAgain_0.ods
- (12.85 KiB) Downloaded 182 times
Last edited by Lupp on Tue Oct 09, 2018 5:59 pm, edited 1 time in total.
On Windows 10: LibreOffice 24.2 (new numbering) and older versions, PortableOpenOffice 4.1.7 and older, StarOffice 5.2
---
Lupp from München
---
Lupp from München
Re: Macro code to add date/time when cell in row changed
Yes, it is true.code contained in the example above has some flaws
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.
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.
Re: Macro code to add date/time when cell in row changed
Thank you soo much Sir.... its worked for me...thanks alot.
LibreOffice Version: 5.1.6.2 on Ubuntu OS Version: :Linux 4.4