Time/Stamp on value change
Time/Stamp on value change
Cell A1= done Cell B1= IF(A1="";"";IF(B1="";NOW();B1))
what I want is, if I modify the cell A1 then it should update cell B1; presently its happening only when I delete the content from cell A1 and then updating it. ( it should happen without deleting the cell; i.e- on instance of modifying also it should update time stamp)
hope i am clear
No Macro pls.
Regards
krijes
what I want is, if I modify the cell A1 then it should update cell B1; presently its happening only when I delete the content from cell A1 and then updating it. ( it should happen without deleting the cell; i.e- on instance of modifying also it should update time stamp)
hope i am clear
No Macro pls.
Regards
krijes
Windows XP / Open office 3.2
Re: Time/Stamp on value change
Does this work?
Code: Select all
=IF(ISBLANK(A1);"";NOW())
OpenOffice 4.1 on Windows 10 and Linux Mint
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
Re: Time/Stamp on value change
Nope it doesn't;FJCC wrote:Does this work?Code: Select all
=IF(ISBLANK(A1);"";NOW())
thought it update the time stamp without deleting the cell content; BUT it update the time stamp on a entry anywhere in the sheet, pls find the attachment to test yourself.
Regards
krijes
Windows XP / Open office 3.2
Re: Time/Stamp on value change
someone pls help; waitig for a solution.. : (
Windows XP / Open office 3.2
Re: Time/Stamp on value change
Why not?No Macro pls.
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.
- MrProgrammer
- Moderator
- Posts: 4908
- Joined: Fri Jun 04, 2010 7:57 pm
- Location: Wisconsin, USA
Re: Time/Stamp on value change
I wanted to do this sort of thing myself a few weeks ago. But after thinking about how formulas work, I came to the conclusion that one cannot do this with Calc formulas. There are at least two problems.
A macro could presumably determine the current date/time and insert it as a value into a cell, but you have ruled that option out.
Calc is a complicated product, and it's possible that this could be accomplished with formulas alone using techniques that I haven't considered, however I think this is unlikely.
This will not work because cell B1 references itself. I was unable to determine an alternate form of this sort of formula which bypasses the self-referrential problem. A second problem is that NOW is a dynamic function whose value changes. It will be recalculated, at minimum, each time the file is saved and opened. You can convert the function into a number (which won't change) using Edit, Copy, Edit, Paste Special, uncheck Formulas, OK, however that is an extra step.krijes wrote:Cell B1= IF(A1="";"";IF(B1="";NOW();B1))
A macro could presumably determine the current date/time and insert it as a value into a cell, but you have ruled that option out.
Calc is a complicated product, and it's possible that this could be accomplished with formulas alone using techniques that I haven't considered, however I think this is unlikely.
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).
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).
- Charlie Young
- Volunteer
- Posts: 1559
- Joined: Fri May 14, 2010 1:07 am
Re: Time/Stamp on value change
I came to the same conclusion as Mr. Programmer as far as doing it with formulas alone. I have written some macros that accomplish the task, so I might as well post them here since no one has to use them if they don't want to. There are problems here concerning the behavior of removeModifyListener, and note that the attached spreadsheet should be treated with caution, as I did experience a few crashes while working on it. Please do not have any valuable unsaved work open at the same time you are experimenting with this.
The attached spreadsheet attaches modify listeners to each cell in Sheet1.A1:A1000 upon file open, and removes them on file close. It seems necessary to set up an array of listeners so as to have a different one for each cell. If the same listener is attached to multiple cells, removeModifyListener only works on event.source.
A modification to column A sets the time in the corresponding row of column B. I have formatted column B to MM/DD HH:MM:SS, but this is unessential, and any desired date/time/number format could be applied.
Again, treat this with caution.
The attached spreadsheet attaches modify listeners to each cell in Sheet1.A1:A1000 upon file open, and removes them on file close. It seems necessary to set up an array of listeners so as to have a different one for each cell. If the same listener is attached to multiple cells, removeModifyListener only works on event.source.
A modification to column A sets the time in the corresponding row of column B. I have formatted column B to MM/DD HH:MM:SS, but this is unessential, and any desired date/time/number format could be applied.
Again, treat this with caution.
- Attachments
-
- timestamped.ods
- Time Stamper
- (11.44 KiB) Downloaded 542 times
Last edited by Charlie Young on Sat Jul 17, 2010 10:50 pm, edited 1 time in total.
Apache OpenOffice 4.1.1
Windows XP
Windows XP
-
- Posts: 48
- Joined: Mon May 31, 2010 9:47 pm
Re: Time/Stamp on value change
The formula works. You avoid the circular reference by checking "Iterations" at Tools>Options>OpenOffice.org Calc>Calculate.MrProgrammer wrote:There are at least two problems.This will not work because cell B1 references itself. I was unable to determine an alternate form of this sort of formula which bypasses the self-referrential problem. A second problem is that NOW is a dynamic function whose value changes. It will be recalculated, at minimum, each time the file is saved and opened. You can convert the function into a number (which won't change) using Edit, Copy, Edit, Paste Special, uncheck Formulas, OK, however that is an extra step.Cell B1= IF(A1="";"";IF(B1="";NOW();B1))
also it doesn't get recalculated when you open or save the file or make changes any where else on the sheet.
The only time the time changes is when you clear cell A1's contents and retype something in it.
The thing with the OP is he doesn't to want clear cell A1 first, because it contains lots of text and he/they don't want to retype it.They Just want to go in and modify the text and have it update.
I suggested in the other forum a where this question is posted a temp. fix could be to add a "Done" cell. which you could just type one word like "done" and easily delete and retype anytime to update the time stamp.but Of coarse the users would have to remember to update the timestamp.
I think Your are right though a formula alone won't do it all and make it totally user proof.
I tried charlies macros they seem work pretty good and did the job.
- Attachments
-
- timestamp_test.ods
- sample of suggestion
- (14.35 KiB) Downloaded 346 times
Apache OpenOffice4.1.2, Windows 7
-
- Posts: 48
- Joined: Mon May 31, 2010 9:47 pm
Re: Time/Stamp on value change
Now probe1 came up with this great custom function for a time stamp:
Place this Function code into the My Macros>STANDARD library of your OOo installation to have the function available in any Calc document
Enter =TimeText() into a cell to get something like: Updated: 2010-07-18 15:30
Code: Select all
Function TimeText
sTime = Format( Now(), "yyyy-mm-dd hh:mm" )
sText = "Updated: "
TimeText = sText & sTime'
End Function
Enter =TimeText() into a cell to get something like: Updated: 2010-07-18 15:30
Last edited by aloarjr810 on Mon Jul 19, 2010 12:19 am, edited 1 time in total.
Apache OpenOffice4.1.2, Windows 7
- Charlie Young
- Volunteer
- Posts: 1559
- Joined: Fri May 14, 2010 1:07 am
Re: Time/Stamp on value change
Unfortunately, both my macro and the TimeText function suffer from the same malady: the timestamps are updated on a hard recalculation (Ctrl-Shift-F9), and in the case of the TimeText function, this is triggered on File > Open.
Further work is needed.
Further work is needed.
Apache OpenOffice 4.1.1
Windows XP
Windows XP
Re: Time/Stamp on value change
Try macro 3a or 3b in
[Calc,Python,Basic,Base] Several ways to time stamps
A text value is not a calculatable date.
[Calc,Python,Basic,Base] Several ways to time stamps
A text value is not a calculatable date.
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
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Re: Time/Stamp on value change
thanx guys,
pls find the attached sheet; it will help you to understand my query more clearly.
I am a newbee to macros and i want to use this sheet as shared sheet on windows NT network hope it will work.
the attached sheet is based on solution give by probe1 in another forum
thanx for your time and help
regards
krijes
pls find the attached sheet; it will help you to understand my query more clearly.
I am a newbee to macros and i want to use this sheet as shared sheet on windows NT network hope it will work.
the attached sheet is based on solution give by probe1 in another forum
probe1 wrote:To return something into a Calc cell you need a user defined function, which -in this case- combines a text and date, formatted to your needs.
This is an example
Place this Function code into the My Macros>STANDARD library of your OOo installation to have the function available in any Calc documentCode: Select all
Function ZeitText sZeit = Format( Now(), "yyyy-mm-dd hh:mm" ) sText = "order from: " ZeitText = sText & sZeit' End Function
Enter =ZeitText() into a cell to get something like: order from: 2010-07-18 15:30
Now you can change the text (and position) or the format of returned time to your like, couldn't you?
thanx for your time and help
regards
krijes
Windows XP / Open office 3.2
Re: Time/Stamp on value change
ur given solutions in above list is too complex and risky for me to apply and test on a shared sheet which is used by lot of technology challenged users..Villeroy wrote:Try macro 3a or 3b in
[Calc,Python,Basic,Base] Several ways to time stamps
A text value is not a calculatable date.
ville cant we have a formula for this ; i mean .. i am sure a lot of user are looking for this kind of solution from a spreadsheet of calc caliber; where we dont need to lower the security bar for macros and yet achieve simple and user friendly spreadsheet.
Windows XP / Open office 3.2
Re: Time/Stamp on value change
You can not do this in any spreadsheet without implementing some kind of macro. The macro simply puts a time stamp into column A when "some other cells" are modified. You've got to install the macro and define "some other cells" through the validation feature.
Use it or lose it.
Use it or lose it.
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
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
-
- Posts: 48
- Joined: Mon May 31, 2010 9:47 pm
Re: Time/Stamp on value change
While this doesn't change on a cell value change.
Heres another manual timestamp using a validity list. (the users would have to change it.)
But it doesn't change on a save, open, hard recalculate or change on the sheet and you dont have to delete your text.
Select cell where you want the time stamp
go to menu Data > validity
In Criteria>Allow>Cell Range & Show selection list
In "Source" enter NOW() click ok.
Format your cell for your time format.
When somebody updates, they just select the time cell and set the current time from the list.
The time stays til you change it again.
Heres another manual timestamp using a validity list. (the users would have to change it.)
But it doesn't change on a save, open, hard recalculate or change on the sheet and you dont have to delete your text.
Select cell where you want the time stamp
go to menu Data > validity
In Criteria>Allow>Cell Range & Show selection list
In "Source" enter NOW() click ok.
Format your cell for your time format.
When somebody updates, they just select the time cell and set the current time from the list.
The time stays til you change it again.
Apache OpenOffice4.1.2, Windows 7
Re: Time/Stamp on value change
thanks to all for helping me on this, BUT still looking for some REAL solution other then macro... as network security policy does not allow me to use macro on a shared sheet.
Many thanks for all of you.
Best Regards
krijes
Many thanks for all of you.
Best Regards
krijes
Windows XP / Open office 3.2
Re: Time/Stamp on value change
Ther REAL and macro free solution for this type of problem would be some network capable database with triggers. If you insist on a calculator as database surrogate you have to extend its capabilities one way or the other.
I have no idea how my time-stamp code for Calc could ever violate any kind of network policy. Like all macros it runs in local context, simply putting a number into a certain cell of the local user's spreadsheet triggered by a local user's data entry.
I have no idea how my time-stamp code for Calc could ever violate any kind of network policy. Like all macros it runs in local context, simply putting a number into a certain cell of the local user's spreadsheet triggered by a local user's data entry.
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
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Re: Time/Stamp on value change
can you pls upload an example calc sheet where entering data on 2nd, 5th and 8th column will trigger time stamp on 3rd,6th and 9th column. i will test it again in my technology challenged shared user environment.(with network security)Villeroy wrote: I have no idea how my time-stamp code for Calc could ever violate any kind of network policy. Like all macros it runs in local context, simply putting a number into a certain cell of the local user's spreadsheet triggered by a local user's data entry.
i have no idea what are these and how to implement it in a technology challenged shared user environment.Villeroy wrote: some network capable database with triggers.
regards
krijes
Windows XP / Open office 3.2
Re: Time/Stamp on value change
Using my validation triggers this is a matter of seconds: Select columns B,E,H and validate text length=-1 triggering macro vnd.sun.star.script:TimeStamp2Calc.py$NowToColumnAByValidation?language=Python&location=userkrijes wrote: can you pls upload an example calc sheet where entering data on 2nd, 5th and 8th column will trigger time stamp on 3rd,6th and 9th column. i will test it again in my technology challenged shared user environment.(with network security)
regards
krijes
For 3 different stamps you need some modified sheet layout or implement some variants with different target columns:
Extract my Python-macro to your user profile and test the attached document with a single target column A.def _NowToColumnCByValidation(sAddr, bOverwrite):
iCol = 2
[...]
def _NowToColumnFByValidation(sAddr, bOverwrite):
iCol = 5
[...]
def _NowToColumnIByValidation(sAddr, bOverwrite):
iCol = 8
[...]
- Attachments
-
- NowToColumnAByValidation.ods
- Example of validation triggered stamp in column A
- (14.83 KiB) Downloaded 361 times
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
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
- Charlie Young
- Volunteer
- Posts: 1559
- Joined: Fri May 14, 2010 1:07 am
Re: Time/Stamp on value change
I vote for Villeroy's macro over mine. The validity method was something I had not thought of, and would seem to produce fewer problems than attaching listeners to all those cells.
Instead of hardcoding it to column A though, it looks to be simple to modify it to set the timestamp cell just to be one to the right of the column with the validity check:
Seems to work, though one might also want to change the macro's name from NowToColumnAByValidation to be perfectly clear.
Instead of hardcoding it to column A though, it looks to be simple to modify it to set the timestamp cell just to be one to the right of the column with the validity check:
Code: Select all
def _NowToColumnAByValidation(sAddr, bOverwrite):
doc = XSCRIPTCONTEXT.getDocument()
s,r = splitStringAddress(sAddr)
sh = doc.Sheets.getByName(s)
rg = sh.getCellRangeByName(r)
iRow = rg.RangeAddress.StartRow
''' Set Timestamp column to be one to the right '''
iCol = rg.RangeAddress.StartColumn + 1
c = sh.getCellByPosition(iCol, iRow)
if bOverwrite or not c.getFormula():
printStamp(c)
Apache OpenOffice 4.1.1
Windows XP
Windows XP
Re: Time/Stamp on value change
Charly,
Thank you for the fix. I'd suggest _NowToNextColumnByValidation as name of your routine.
Turning constant iCol into a parameter brings some flexibility:
Thank you for the fix. I'd suggest _NowToNextColumnByValidation as name of your routine.
Turning constant iCol into a parameter brings some flexibility:
Code: Select all
def _NowToColumn_ByValidation(sAddr, bOverwrite, iCol):
doc = XSCRIPTCONTEXT.getDocument()
s,r = splitStringAddress(sAddr)
sh = doc.Sheets.getByName(s)
rg = sh.getCellRangeByName(r)
iRow = rg.RangeAddress.StartRow
c = sh.getCellByPosition(iCol, iRow)
if bOverwrite or not c.getFormula():
printStamp(c)
def NowToEmptyColumnAByValidation(sFormula, sAddr):
'''Current time to empty column A, triggered by failing validation'''
# passing over column #0 (A)
_NowToColumn_ByValidation(sAddr, False, 0)
def NowToColumnAByValidation(sFormula, sAddr):
'''Current time to column A, triggered by failing validation'''
# passing over column #0 (A)
_NowToColumn_ByValidation(sAddr, True, 0)
# for any other column you need...
def NowToEmptyColumnCByValidation(sFormula, sAddr):
# passing over column #2 (C)
_NowToColumn_ByValidation(sAddr, False, 2)
def NowToColumnCByValidation(sFormula, sAddr):
# passing over column #2 (C)
_NowToColumn_ByValidation(sAddr, True, 2)
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
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Re: Time/Stamp on value change
many thanx ville, charlie. but i cant use in my server security environment.. server and security is outsourced to third party here and we cant tweak them ..
Windows XP / Open office 3.2
Re: Time/Stamp on value change
How can the evil power know that a local office-macro typed data into spreadsheet cells?krijes wrote:many thanx ville, charlie. but i cant use in my server security environment.. server and security is outsourced to third party here and we cant tweak them ..
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
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Re: Time/Stamp on value change
will post the screen shot from shared user machine..., once i get there
Windows XP / Open office 3.2
Re: Time/Stamp on value change
Thanks a lot for all the posts above.
On using the macro TimeStamp2Calc I am facing a problem, it works really well unless you paste the value into the cell.
Any ideas??
Thanks
On using the macro TimeStamp2Calc I am facing a problem, it works really well unless you paste the value into the cell.
Any ideas??
Thanks
Openoffice 3.4 Windows XP Pro
Re: Time/Stamp on value change
A database is the one and only clean solution for this. When you paste cells over other cells, the other cells are completely overwritten (values, formulas, formatting, conditional formatting, validation included).gordix1 wrote:Thanks a lot for all the posts above.
On using the macro TimeStamp2Calc I am facing a problem, it works really well unless you paste the value into the cell.
Any ideas??
Thanks
The dirty hack would be a listener macro as suggested by Charly. Without being really sure, I think that this mechanism wouldn't be affected by a copy and paste.
Spreadsheets are horrible tools for advanced list keeping even though the vast majority of today's users use it exactly for that purpose.
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
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
- Charlie Young
- Volunteer
- Posts: 1559
- Joined: Fri May 14, 2010 1:07 am
Re: Time/Stamp on value change
I've been looking at this, and I suspect it is a bug. Even if you do a Paste Special, so as not to change the validation settings, it still doesn't work.Villeroy wrote:A database is the one and only clean solution for this. When you paste cells over other cells, the other cells are completely overwritten (values, formulas, formatting, conditional formatting, validation included).gordix1 wrote:Thanks a lot for all the posts above.
On using the macro TimeStamp2Calc I am facing a problem, it works really well unless you paste the value into the cell.
Any ideas??
Thanks
The dirty hack would be a listener macro as suggested by Charly. Without being really sure, I think that this mechanism wouldn't be affected by a copy and paste.
Spreadsheets are horrible tools for advanced list keeping even though the vast majority of today's users use it exactly for that purpose.
I also thought about writing some macro to attach to the documents "'Modified' status was changed" event, having the macro check if the current selection is a cell with the validation condition, and running the timestamp macro if it does. I can't think of a way to make this foolproof though; if the modified status were to be changed by something other than a cell entry, say by saving the document, it might also change a timestamp inappropriately.
Maybe something can be done with the listeners, but I think that would require attaching a listener to every cell in question, and would be very cumbersome.
Apache OpenOffice 4.1.1
Windows XP
Windows XP
Re: Time/Stamp on value change
LibreOffice provides events in the context menu of a sheet tab.
Right-click>Sheet Events...
Activate Doc
DeActivate Doc
Selection Changed
Double Click
Right Click
Forumulas calculated
Content changed
Judging from my experience with LibO (and adding a grain of fatalism) it is one of those good looking but untested features which may work, crash or do nothing at all.
Right-click>Sheet Events...
Activate Doc
DeActivate Doc
Selection Changed
Double Click
Right Click
Forumulas calculated
Content changed
Judging from my experience with LibO (and adding a grain of fatalism) it is one of those good looking but untested features which may work, crash or do nothing at all.
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
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Re: Time/Stamp on value change
I never noticed the sheet events in OpenOffice but the feature exists in AOO 3.4 as well.
This code puts the time stamp into column A in whatever row you modify (edit, delete, paste) some cell or rectangular cell range.
This code puts the time stamp into column A in whatever row you modify (edit, delete, paste) some cell or rectangular cell range.
Code: Select all
import uno
from com.sun.star.sheet.FillDirection import TO_BOTTOM, TO_TOP, TO_RIGHT, TO_LEFT
from com.sun.star.sheet.FillMode import SIMPLE
def NowToColumnA(r):
'''To be called by LibreOffice sheet event "Content Changed".
Argument r is the modified cell or range'''
a = r.getRangeAddress()
sh = r.getSpreadsheet()
oTarget = sh.getCellRangeByPosition(0, a.StartRow, 0, a.EndRow)
c = oTarget.getCellByPosition(0,0)
c.setFormula("=NOW()")
oTarget.fillSeries(TO_BOTTOM, SIMPLE,0,0,0)
oTarget.setDataArray(oTarget.getDataArray())
g_exportedScripts = NowToColumnA,
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
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Re: Time/Stamp on value change
Hallo
Slightly changed:
Karo
Slightly changed:
Code: Select all
from datetime import datetime as d
def NowToColumnA(r):
'''To be called by LibreOffice sheet event "Content Changed".
Argument r is the modified cell or range'''
a = r.getRangeAddress()
sh = r.getSpreadsheet()
oTarget = sh.getCellRangeByPosition(0, a.StartRow, 0, a.EndRow)
f = '%Y-%m-%d %H:%M:%S'
nows = ((d.now().strftime( f ),),) * (1 + a.EndRow - a.StartRow)
oTarget.setFormulaArray( nows )
Libreoffice 7.4 on Debian 12 (Bookworm) (on RaspberryPI4)
Libreoffice 7.6 flatpak on Debian 12 (Bookworm) (on RaspberryPI4)