Ask Your Question
0

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

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

Ramesh K gravatar image

updated 2020-07-21 06:16:09 +0200

Alex Kemp gravatar image

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 reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by Alex Kemp
close date 2020-07-21 06:16:17.132733

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

Question Tools

1 follower

Stats

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

Seen: 146 times

Last updated: Mar 09 '16