How to delete the rows with strikethrough on column A among multiple sheets

homing

New Member
Joined
Nov 24, 2013
Messages
2
Hello,

I have a workbook with multiple sheets. I want to use VBA macro to delete the row where the first column is strikethrough. I try to the follow VBA code but it doesn't work. Could someone help me to solve this issue? Thanks in advance!

Sub Macro1()
Dim cell As Range
Dim delRange As Range

'Dim Wkb As Workbook
Dim WS As Worksheet

Application.EnableEvents = False
Application.ScreenUpdating = False

Workbooks.Open Filename:="D:\reaserch\DeleteStrikeThroughs.xlsx"
For Each WS In ActiveWorkbook.Worksheets

For Each cell In Range("A1:A" & _
Range("A" & Rows.Count).End(xlUp).Row)
If cell.Font.Strikethrough Then
If delRange Is Nothing Then
Set delRange = cell
Else
Set delRange = Union(delRange, cell)
End If
End If
Next cell
If Not delRange Is Nothing Then delRange.EntireRow.Delete
Next WS
ActiveWorkbook.Save
ActiveWorkbook.Close

End Sub
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
homing,

Welcome to the MrExcel forum.

What version of Excel and Windows are you using?


The Font.Strikethrough's are not displaying correctly - now displayed with Font.Strikethrough's in bold font.

Sample raw data in two worksheets:


Excel 2007
A
1one
2two
3three
4four
5five
6six
7seven
8eight
9nine
10ten
11
Sheet1



Excel 2007
A
1one
2two
3three
4four
5five
6six
7seven
8eight
9nine
10ten
11
Sheet2


After the macro:


Excel 2007
A
1one
2three
3five
4six
5seven
6ten
7
8
9
10
11
Sheet1



Excel 2007
A
1two
2four
3five
4seven
5eight
6nine
7
8
9
10
11
Sheet2


Please TEST this FIRST in a COPY of your workbook (always make a backup copy before trying new code, you never know what you might lose).

Code:
Option Explicit
Sub Macro1_V2()
' hiker95, 11/24/2013
' http://www.mrexcel.com/forum/excel-questions/741348-how-delete-rows-strikethrough-column-among-multiple-sheets.html
Dim r As Long, lr As Long
Dim WS As Worksheet
Application.EnableEvents = False
Application.ScreenUpdating = False
Workbooks.Open Filename:="D:\reaserch\DeleteStrikeThroughs.xlsx"
For Each WS In ActiveWorkbook.Worksheets
  With WS
    lr = .Cells(Rows.Count, 1).End(xlUp).Row
    For r = lr To 1 Step -1
      If .Cells(r, 1).Font.Strikethrough = True Then .Rows(r).Delete
    Next r
  End With
Next WS
ActiveWorkbook.Save
ActiveWorkbook.Close
Application.EnableEvents = True
Application.ScreenUpdating = True
End Sub

Before you use the macro with Excel 2007 or newer, save your workbook, Save As, a macro enabled workbook with the file extension .xlsm

Then run the Macro1_V2 macro.
 
Last edited:
Upvote 0
Hello Hiker95,

I use win xp and office 2007. The code you provided works! Thanks a lot for your kindly help!
 
Upvote 0
homing,

Thanks for the feedback.

You are very welcome. Glad I could help.

And, come back anytime.
 
Upvote 0

Forum statistics

Threads
1,223,919
Messages
6,175,368
Members
452,638
Latest member
Oluwabukunmi

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top