Show or hide rows when text is bold or italic

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi, sorry to bother everyone again but I'm desperate... is there a way to
show or hide rows (like you would with autofilter) but based on the
formatting of the cells rather than the content? I need to be able to show
only bold rows or only italic rows. Many thanks,
SP
 
Start in the column you want to evaluate. It stops when it hits a blank cell.
Sub Macro1()
Do Until ActiveCell.Value = ""
If Selection.Font.Bold = True Then
ThisAddress = ActiveCell.Address
ActiveCell.Rows("1:1").EntireRow.Select
Selection.EntireRow.Hidden = True
Range(ThisAddress).Select
ActiveCell.Offset(1, 0).Range("A1").Select
Else
ActiveCell.Offset(1, 0).Range("A1").Select
End If
Loop
End Sub
Hope it helps
 
The following code should do what u want.


lastrow = Cells(Rows.Count, 1).End(xlUp).Row + 1
Range("a1").Select

Do Until ActiveCell.Row = lastrow

If Selection.Font.Bold = True Then
ActiveCell.Rows.Hidden = True
ActiveCell.Offset(rowoffset:=1).Activate
Else: ActiveCell.Offset(rowoffset:=1).Activate

End If

Loop

HTH
Devin
 
I do not know of any built-in ways to do such a thing, but you could
write VBA code to loop through the UsedRange.Rows and if .font.bold or
..font.italic in the first cell in the row is true then do a
Rows.Hidden = True

Short example:

Sub HideBoldRows()
For Each Element In ActiveSheet.UsedRange.Rows
If Element.Range("A1").Font.Bold = True Then _
Element.Rows.Hidden = True
Next Element
End Sub


Billkamm
irc.24oz.net #Excel
 

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