Monday, December 12, 2011

How can I have an if statement return a date that doesn't change (i.e. doesn't update like TODAY function)

You set the onclick event of the button to return the current date via a VBA function.





It won't change if you set the date as a literal in your function.|||An if statement by definition doesn't return anything. It tests whether an expression is true or false, then acts upon that test. What are you trying to do?|||what particular programming language?|||Not sure what you are trying to accomplish but sounds like you want to store the date in a global variable after you have retrieved it...





...So your using VBA. Just store the date the first time you retrieve it either in a global variable or a cell in the spreadsheet. Global if you need it for the life of the open spreadsheet, or cell if you need it permanently.|||What programming language or other software? What OS?|||If you use the check box event, then when it is checked the TODAY function writes the date to a new cell. When saved, that date should remain.





You don't want to test to see if the box is checked--you want to do something at the moment it is checked. So it won't update the date every time the sheet is opened--only every time the checkbox is changed from unchecked to checked.





Hope that helps

No comments:

Post a Comment