How to delete words formatted as strikethrough?

Hi!

How to delete the aforementioned in the LibreOffice Calc?

How to delete words formatted as strikethrough?

If these content are formatted by usage the Cell Styles, then you can use the Find and Replace feature.

Can you upload an ODF type sample file here?

I can upload xlsx sample which I am trying to edit with libreoffice.
Sample.xlsx (5.0 KB)

  1. You will need user code.
  2. Code working with text portions inside a cell would be very complicated.
  3. Code contained in a document stored by LibreOffice in an alien format (.xlsx e.g.) will not contain the user code, and can therefore not run it when loaded with any Excel or reloaded with LibreOffice.
  4. If you are nevertheless interested in code working with complete cells, see attached example.
    disask113668_SampleRe2.ods (39.2 KB)
    (There was a correction.)
    The claim under Number 2. is not quite correct. I considered again, and found that removal per TextPortion isn’t too complicated. The new example attached below does, however, not look for words.
    disask113668_RemoveStrikedoutTextPortionWise.ods (38.3 KB)

Just for clarificacion:
a. The strikethrough attribute is applied to some words in some cells?
b. The strikethrough attribute is applied to complete cells, as in your sample file?
c. Do you need to delete the words that are formatted with strikethrough?

ask113668.ods (31.8 KB)

  1. Tools>Options>Security, button [Macro Security…]
  2. Set highest security level and add your documents directory to the list of trusted sources (not! your downloads directory).
  3. Save my attachment to that directory or any subdirectory therein.
  4. Open the file in that trusted directory. You see a filterable list with numeric formula results in column B. 1 means single strike-through, 2 means double strike-through. In order to make use of this table, use the drop-down in B1, remove the check mark from “0”, click [OK]. Then select column A of the filtered cell range and clear the cell contents or delete entire rows.
    In order to use the function in all your documents:
  5. Tools>Macros>Organize>Basic, button [Organizer…]
  6. Drag the module “modCELL” from my document’s “Standard” library to the “Standard” library under “My Macros”.

The user-defined functions on that module return certain property values of cells or sheets. They need to be recalculated manually. For instance, when you remove some strike-through from a cell in my sample file, the formula in column B is not recalculated accordingly. Hit Ctrl+Shift+F9 to enforce recalculation.
The formula is: =CELL_PROPERTY("CharStrikeout";SHEET();ROW();1) which returns the property value “CharStrikeout” of the cell on this sheet, this row, column 1. The property name is case sensitive “CharStrikeOut” fails.
On the second sheet of my sample you find a filtered list of supported property names in column A with “CharStrikeout” in cell A54.

After removing the check mark from “0” and clicking [OK], all the cells still have strike-through. What am I doing or understanding wrong?

This step hides away the cells without strikethrough, so you can edit the remaining visible cells in one go. Select them all and either remove the formatting or clear contents (Del key) or delete the entire rows. Then remove the filter.

I think we misunderstood each other. I want to delete the word(s) with strike-through within cell, not the entire cell that have no strike-through.
All my cells have strike-through, even the ones in the example.

So did you see the second example by @Lupp ?

By calling the Sub, the cell becomes empty. What am I doing wrong?

What cell?
I’m afraid you either didn’t try the second attachment, or you didn’t read the explanations.
Note that the cells in column A contain only striked-through text. Try all the colored cells.

I think I didn’t read the explanations.
Now I can achieve what I wanted with the whole document. Thank you!

where complete cells have the strikethroufh attribute. My solution was based on this information.

2 Likes

a. Nope I guess.
b. As in my sample file.
c. Yes.

Kontakt LeroyG via Ask LibreOffice (<noreply@ask.libreoffice.org>) kirjutas kuupäeval E, 11. november 2024 kell 02:11:

This is not a solution to your problem; please re-post as a comment and delete this non-answer.