Page 1 of 1

[Solved] How to prevent certain cells from being saved?

Posted: Thu Sep 16, 2021 12:47 pm
by BennyRayRiddle
Is there a way to designate certain cells for which their value is NOT saved when the spreadsheet is saved?

Each line of my spreadsheet looks like this:

Code: Select all

ItemNumber    InventoryCount    PhysicalCount   Difference
The InventoryCount is automatically updated on opening by a link to another file and the Difference is just InvetoryCount - PhysicalCount. I want to be able to designate the PhysicalCount cells so that if the spreadsheet is saved their values are not saved with it. Is this possible? I haven't been able to find an answer here or on general Google searching.

Re: How to prevent certain cells from being saved?

Posted: Thu Sep 16, 2021 4:12 pm
by FJCC
One way to do this is to have a macro delete the numeric values from column C when the file is saved. The attached file has that set up. I used the Events tab from the menu item Tools -> Customize to assign the macro to the Save Document event. Here is the macro code

Code: Select all

Sub ClearColC
 oSheets = ThisComponent.getSheets()
 oObj1 = oSheets.getByName("Sheet1")
 oColumns = oObj1.getColumns()
 oObj2 = oColumns.getByName("C")
 oObj2.clearContents(1) `the 1 causes numeric values to be deleted.
End Sub
You can access the macro through the menu Tools -> Macros -> Organize Macros -> OpenOffice Basic. You then expand the listing for the ClearColC.ods document and look in the Standard library and in Module1.

Re: How to prevent certain cells from being saved?

Posted: Thu Sep 16, 2021 5:39 pm
by Villeroy
Without macro, a scenario range with blank cells can do the trick. In http://forum.openoffice.org/en/forum/do ... hp?id=3004 the scenario "New Empty" can be filled out but when you switch to another one, it remains empty.

Re: How to prevent certain cells from being saved?

Posted: Fri Sep 17, 2021 9:46 am
by BennyRayRiddle
Thanks. It looks like a macro to clear the cells is the closest to what I want. I borrowed the macro code from viewtopic.php?t=23481 so that unprotected cells are cleared instead of wiping the column.