ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Ideal Code deleting rows/based on bold text (https://www.excelbanter.com/excel-programming/294659-ideal-code-deleting-rows-based-bold-text.html)

Samm

Ideal Code deleting rows/based on bold text
 
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?



Rob van Gelder[_4_]

Ideal Code deleting rows/based on bold text
 
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


--
Rob van Gelder - http://www.vangelder.co.nz/excel


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






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

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