Page 1 of 1

Input today date if change

PostPosted: Wed Nov 09, 2016 11:11 am
by msalsinha
Hello

I wanted to create a function or a macro that whenever I modify a certain cell with a certain content it marks the date of today without coming back to update unless I change the contents of the cell again.

Can someone help me?

Re: INPUT TODAY DATE IF CHANGE

PostPosted: Wed Nov 09, 2016 11:46 am
by Zizi64
You can use a form control element for the value modification. In this case you can assign your timeStamp macro to the "click on" event of the form control element. Or you can create a listener (changed event) for the cell. Search the word "Listener" in the macro forum.

Note:
A click on the form control element not will always mean : "The cell content is changed", as the manual input (typing some data into a cell) not always mean : "The cell content is changed", because you maybe typed in same value as the cell was contained. But the event will activated, when you edit a cell. My opinion you need store the previous content of the examined cell (into a global macro variable) for the exact detecting of the change.

Re: INPUT TODAY DATE IF CHANGE

PostPosted: Wed Nov 09, 2016 1:36 pm
by msalsinha
Let me demonstrate what exactly I try to do.

Whenever in the "ESTATE" column I change the state of each cell, in the "DATE" column will appear the date when the change was made.

Image

Re: Input today date if change

PostPosted: Wed Nov 09, 2016 5:52 pm
by Villeroy
menu:Tools>Options...OOoCalc>Calculate: Enable iteration with 1 step
Code: Select all   Expand viewCollapse view
=IF(A1="";"";IF(B1="";NOW();B1))

Re: Input today date if change

PostPosted: Wed Nov 09, 2016 9:31 pm
by Zizi64

Re: Input today date if change

PostPosted: Wed Nov 09, 2016 11:14 pm
by Zizi64
A simple example with Combobox and macro:

DateTime of change.ods
(13.75 KiB) Downloaded 80 times

Re: Input today date if change

PostPosted: Wed Nov 09, 2016 11:28 pm
by Zizi64
Modified example. The scope of the macro is limited to the cells have custom cell style, named "InputCells".

DateTime of change2.ods
(14.02 KiB) Downloaded 95 times