View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_6_] Bob Phillips[_6_] is offline
external usenet poster
 
Posts: 11,272
Default Remove all rows with bold text

This will delete any row that is not all bold. So if one cell is bold,
another is not, it's gone.

Sub DeleteNotBold()
Dim iLastRow As Long
Dim iLastCol As Long
Dim i As Long
Dim j As Long
Dim fbold As Boolean

iLastRow = Cells.Find(What:="*", _
After:=Range("A1"), _
SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious).Row

For i = iLastRow To 1 Step -1
iLastCol = Cells(i, Columns.Count).End(xlToLeft).Column
fbold = True
For j = 1 To iLastCol
If Not Cells(i, j).Font.Bold Then
fbold = False
Exit For
End If
Next j
If Not fbold Then Rows(i).Delete
Next i
End Sub


--

HTH

RP
(remove nothere from the email address if mailing direct)


"MrAle" wrote in
message ...

Hello,

I need to create a macro that removes all rows with none bold text.
Text can be in any cell.

Down below is a macro I created, but it only removes if the selected
cell contains none bold stuff.

I'm kinda new to VBA so a working macro would be greate!
Thanks

++++++++++++++++++++++++++++
Sub Testi()

On Error GoTo quit
If Selection.Font.Bold = False Then
Selection.EntireRow.Delete
End If

quit:

End Sub
++++++++++++++++++++++++++++


--
MrAle
------------------------------------------------------------------------
MrAle's Profile:

http://www.excelforum.com/member.php...o&userid=26868
View this thread: http://www.excelforum.com/showthread...hreadid=401073