Przejdź do głównej zawartości

Jak usunąć lub usunąć wszystkie przekreślone teksty lub znaki z komórek w programie Excel?

W tym artykule mowa o usunięciu wszystkich przekreślonych tekstów lub znaków z wielu komórek w programie Excel.

Usuń wszystkie przekreślone teksty z komórek za pomocą kodu VBA


Usuń wszystkie przekreślone teksty z komórek za pomocą kodu VBA

Poniższy kod VBA może pomóc w usunięciu wszystkich tekstów w komórkach, które zostały oznaczone przekreśleniem. Wykonaj następujące czynności.

1. W arkuszu zawierającym przekreślone teksty, które należy usunąć, naciśnij inny + F11 klawisze jednocześnie, aby otworzyć Microsoft Visual Basic for Applications okno.

2. w Microsoft Visual Basic for Applications kliknij Wstawka > Moduł. Następnie skopiuj i wklej poniższy kod VBA do okna Code.

Kod VBA: Usuń wszystkie przekreślone teksty z komórek

Sub DelStrikethroughText()
    Dim xRg As Range, xCell As Range
    Dim xStr As String
    Dim I As Long
    On Error Resume Next
    Set xRg = Application.InputBox("Please select range:", "KuTools For Excel", Selection.Address, , , , , 8)
    If xRg Is Nothing Then Exit Sub
    Application.ScreenUpdating = Fase
        For Each xCell In xRg
            If IsNumeric(xCell.Value) And xCell.Font.Strikethrough Then
                xCell.Value = ""
            ElseIf Not IsNumeric(xCell.Value) Then
                For I = 1 To Len(xCell)
                    With xCell.Characters(I, 1)
                        If Not .Font.Strikethrough Then
                            xStr = xStr & .Text
                        End If
                    End With
                Next
                xCell.Value = xStr
                xStr = ""
            End If
        Next
    Application.ScreenUpdating = True
End Sub

3. wciśnij F5 lub kliknij run przycisk, aby uruchomić kod. W wyskakującym okienku Kutools dla programu Excel W oknie dialogowym wybierz zakres zawierający przekreślone teksty, które chcesz usunąć, a następnie kliknij OK przycisk. Zobacz zrzut ekranu:

Następnie wszystkie teksty oznaczone przekreśleniem są natychmiast usuwane z komórek, jak pokazano poniżej.


Podobne artykuły:

Najlepsze narzędzia biurowe

🤖 Pomocnik AI Kutools: Zrewolucjonizuj analizę danych w oparciu o: Inteligentne wykonanie   |  Wygeneruj kod  |  Twórz niestandardowe formuły  |  Analizuj dane i generuj wykresy  |  Wywołaj funkcje Kutools...
Popularne funkcje: Znajdź, wyróżnij lub zidentyfikuj duplikaty   |  Usuń puste wiersze   |  Łącz kolumny lub komórki bez utraty danych   |   Okrągły bez wzoru ...
Super wyszukiwanie: Wiele kryteriów VLookup    Wiele wartości VLookup  |   Przeglądanie pionowe na wielu arkuszach   |   Wyszukiwanie rozmyte ....
Zaawansowana lista rozwijana: Szybko twórz listę rozwijaną   |  Zależna lista rozwijana   |  Lista rozwijana wielokrotnego wyboru ....
Menedżer kolumn: Dodaj określoną liczbę kolumn  |  Przesuń kolumny  |  Przełącz stan widoczności ukrytych kolumn  |  Porównaj zakresy i kolumny ...
Polecane funkcje: Fokus siatki   |  Widok projektu   |   Duży pasek formuły    Menedżer skoroszytów i arkuszy   |  Biblioteka zasobów (Automatyczny tekst)   |  Selektor dat   |  Połącz arkusze   |  Szyfruj/odszyfruj komórki    Wysyłaj e-maile według listy   |  Super filtr   |   Specjalny filtr (filtruj pogrubienie/kursywa/przekreślenie...) ...
15 najlepszych zestawów narzędzi12 Tekst Tools (Dodaj tekst, Usuń znaki, ...)   |   50 + Wykres rodzaje (Wykres Gantta, ...)   |   40+ Praktyczne Wzory (Oblicz wiek na podstawie urodzin, ...)   |   19 Wprowadzenie Tools (Wstaw kod QR, Wstaw obraz ze ścieżki, ...)   |   12 Konwersja Tools (Liczby na słowa, Przeliczanie walut, ...)   |   7 Połącz i podziel Tools (Zaawansowane wiersze łączenia, Podział komórki, ...)   |   ... i więcej

Zwiększ swoje umiejętności Excela dzięki Kutools for Excel i doświadcz wydajności jak nigdy dotąd. Kutools dla programu Excel oferuje ponad 300 zaawansowanych funkcji zwiększających produktywność i oszczędzających czas.  Kliknij tutaj, aby uzyskać funkcję, której najbardziej potrzebujesz...

Opis


Karta Office wprowadza interfejs z zakładkami do pakietu Office i znacznie ułatwia pracę

  • Włącz edycję i czytanie na kartach w programach Word, Excel, PowerPoint, Publisher, Access, Visio i Project.
  • Otwieraj i twórz wiele dokumentów w nowych kartach tego samego okna, a nie w nowych oknach.
  • Zwiększa produktywność o 50% i redukuje setki kliknięć myszką każdego dnia!
Comments (10)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Hey guys, this worked for me but in some cases it somehow changes the text which is not formatted as strikethrough as strikethrough. Easy fix to go back and spotcheck the data in specific instances and un-strikethrough the range.
This comment was minimized by the moderator on the site
Hi,Which Excel version are you using?
This comment was minimized by the moderator on the site
I use it for the whole column and my excel never come back....
This comment was minimized by the moderator on the site
Hi san,
Would you provide the Excel version you are using?
The code works well in my case.
Sorry for the inconvenience.
This comment was minimized by the moderator on the site
can it be done through python, pandas ?
If yes can anybody help me out how to implement this ?
This comment was minimized by the moderator on the site
Hi Girish,
The code hasn't been tested in python, pandas. Sorry can't help you with that. Thanks for commenting.
This comment was minimized by the moderator on the site
This does not work. Excel goes into Not Responding.
This comment was minimized by the moderator on the site
It works in small scale. I assume that the reason it goes into Not Responding is because the Macro takes forever when you have a lot of data to get through. This Macro is checking every single character for strike through.

I would recommend adding code that reformats the cell when it is done because I had several cells where the code removed the strikethrough text but the remaining text was still in strikethrough. I believe this is because the formatting of the full cell was strikethrough with the non strikethrough text being formatted differently, so just an FYI.
This comment was minimized by the moderator on the site
Good day,
Sorry for the inconvenience. Would you provide your Office version? Thanks for your comment.
This comment was minimized by the moderator on the site
Same here.

I am using Office 365 ProPlus
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations