Sunday, 22 December 2019

How to Deleting rows containing bold text in Excel



1.  First open VBS (Alt + F11)

2. Then Select Sheet and Paste Below Code 


3. Last Step Run Macro (F5).

4. That's it.


Sub del_rows_with_bold()
   ' David McRitchie, 2005-09-01
    Application.ScreenUpdating = False
    Application.Calculation = xlCalculationManual
    Dim Rcnt As Long, Ccnt As Long, r As Long, c As Long
    Dim CurrCell As Range
    On Error Resume Next
    Rcnt = Cells.SpecialCells(xlLastCell).Row
    Ccnt = Cells.SpecialCells(xlLastCell).Column
    '-- check up to row 2 from the bottom
    For r = Rcnt To 2 Step -1
       '-- check all cells on row beginning at column 1
       For c = 1 To Ccnt
         If Cells(r, c).Font.Bold And Not IsEmpty(Cells(r, c)) Then
            '-- Must be bold and have content
            Cells(r, c).EntireRow.Delete
            GoTo next_r
        End If
      Next c
next_r:
    Next r
    Application.Calculation = xlCalculationAutomatic
    Application.ScreenUpdating = True
End Sub

No comments:

Post a Comment