ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Code to NOT include row 1 and 2 (https://www.excelbanter.com/excel-programming/323835-code-not-include-row-1-2-a.html)

Annette[_5_]

Code to NOT include row 1 and 2
 
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



Tom Ogilvy

Code to NOT include row 1 and 2
 
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

--
Regards,
Tom Ogilvy

"Annette" wrote in message
...
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





Don Guillett[_4_]

Code to NOT include row 1 and 2
 
try
for i =2 to .Cells(Rows.Count, 1).End(xlUp).Row
code
next

--
Don Guillett
SalesAid Software

"Annette" wrote in message
...
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





Don Guillett[_4_]

Code to NOT include row 1 and 2
 
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

--
Don Guillett
SalesAid Software

"Annette" wrote in message
...
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






All times are GMT +1. The time now is 12:23 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com