Ideal Code deleting rows/based on bold text

  • Thread starter Thread starter Samm
  • Start date Start date
S

Samm

Is a code run where it selects only the lines that have bolded text plus one
(above) and delete all others lines that are not qualified. Is this
possible?

Say, there are bold number or text found on rows 5, 8, 12, 22. When the
code runs, it would delete rows

1, 2, 3, 6, 9, 10, 13, 14, 15, 16, 17, 18, 19, and 20.

Can this be done?
 
Sub test()
Dim i As Long

With ActiveSheet
i = .Cells(Rows.Count, 1).End(xlUp).Row

Do Until i < 1
If .Cells(i, 1).Font.Bold = True Then
i = i - 2
Else
.Rows(i).Delete xlShiftUp
i = i - 1
End If
Loop
End With
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top