ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Show or hide rows when text is bold or italic (https://www.excelbanter.com/excel-programming/318076-show-hide-rows-when-text-bold-italic.html)

Sophisticated Penguin

Show or hide rows when text is bold or italic
 
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

David

Show or hide rows when text is bold or italic
 
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
"Sophisticated Penguin" wrote:

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


Dmoney

Show or hide rows when text is bold or italic
 
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
-----Original Message-----
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
.


Billkamm

Show or hide rows when text is bold or italic
 
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

Sophisticated Penguin wrote in message ...
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


Sophisticated Penguin

Show or hide rows when text is bold or italic
 
Thank you all very much - most helpful!


All times are GMT +1. The time now is 03:40 AM.

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