Increment single cell value by one on every print in calc

Hello everyone,

I wanna know if it is possible to increment single cell value by one on every print using some macro or programming?
Example i have value of 1 in A1 cell, after i print the sheet i want to increment to 2, A1+1, simple enough.

Best regards,
Djordje

Hi, you can try the print document event, on tools - customize - events.

Sub increment
cell = ThisComponent.Sheets(0).getcellrangebyname("A1")
cell.Value = cell.Value + 1

End Sub

Otherwise, you can use a macro to print the document and increment cell A1 at the end.

I got it to work but im trying something different now. I want to have one document when i click save, it saves a copy with some name and it increments the number in the opened file. So basically i open file1 and click save, file2 is created and file1 is still open and number is incremented in file1 and i continue to work on file1. Is that possible?

I’ll answer you from my mobile phone, among the other available events there should also be save document with name, this should be useful to you.
I can’t do tests

1 Like

Worked, thank you very much.