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

Discuss the spreadsheet application
Post Reply
BennyRayRiddle
Posts: 2
Joined: Thu Sep 16, 2021 5:40 am

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

Post 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.
Last edited by robleyd on Fri Sep 17, 2021 11:30 am, edited 2 times in total.
Reason: Add green tick
OpenOffice 4 on Win10
FJCC
Moderator
Posts: 9248
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

Re: How to prevent certain cells from being saved?

Post 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.
Attachments
ClearColC.ods
(11.25 KiB) Downloaded 88 times
OpenOffice 4.1 on Windows 10 and Linux Mint
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
User avatar
Villeroy
Volunteer
Posts: 31269
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: How to prevent certain cells from being saved?

Post 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.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
BennyRayRiddle
Posts: 2
Joined: Thu Sep 16, 2021 5:40 am

Re: How to prevent certain cells from being saved?

Post 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.
OpenOffice 4 on Win10
Post Reply