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
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