Code to NOT include row 1 and 2

A

Annette

I use this code to remove nonbolded items ... but now I realize it can not
and should not touch headings which happen to be in row 1 and 2. Can
someone tell me what should be written so it doesn't touch those two rows?

Sub RemoveNonBoldedRows()
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
Range("A1").Select

End Sub
 
T

Tom Ogilvy

Sub RemoveNonBoldedRows()
Dim i As Long
With ActiveSheet
i = .Cells(Rows.Count, 1).End(xlUp).Row

Do Until i < 3
If .Cells(i, 1).Font.Bold = True Then
i = i - 2
Else
.Rows(i).Delete xlShiftUp
i = i - 1
End If
Loop
End With
Range("A1").Select
 
D

Don Guillett

try this
Sub deletebolded()
For i = Cells(Rows.Count, 1).End(xlUp).row To 3 Step -1
If Cells(i, 1).Font.Bold Then Rows(i).Delete
Next
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

Top