Ask Your Question
0

How to write Libre Office Calc Macro for update and add or less one day each

asked 2016-03-09 18:25:08 +0200

Ramesh K gravatar image

updated 2016-03-09 18:27:21 +0200

I want to update current date in a Libre Office Calc worksheet cell and add or less one day each in same cell using push button and macro. Please help me.

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
0

answered 2016-03-09 21:58:41 +0200

Ratslinger gravatar image

It is not exactly clear what you wish but here is a macro to increase the date in cell A1 by one day. Assign this to the Execute Action event of a push button. Duplicate the macro with the one line changed to decrease the date & attach to second push button.

Sub IncDate
    oSheet=ThisComponent.CurrentController.ActiveSheet
    Cell = oSheet.GetCellRangeByName("A1")
    myDate = Cell.getString
    currMonth = Month(myDate)
    currDay = Day(myDate)
    currYear = Year(myDate)
    serialDate = DateSerial( currYear, currMonth, currDay )
    'Replace next line with serialDate = serialDate-1  to decrease date
    serialDate = serialDate+1
    Cell.setString(serialDate) 
End Sub
edit flag offensive delete link more

Comments

It works.... Thank you

Ramesh K gravatar imageRamesh K ( 2016-03-11 02:49:22 +0200 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2016-03-09 18:25:08 +0200

Seen: 144 times

Last updated: Mar 09 '16