Find "X", bold entire row

L

limpuiting

I want to BOLD entire row where a cell contains text "X" in any cell
in
range(active sheet).

I had tried the below macro, it did bold the row contained text "X".
However everytime when I run this macro my excel program hang. Does
anyone has the solution?



Sub PutInBoldXs()
Dim r As Range
With Range("A1:C30")
Set r = .Find("X", LookIn:=xlValues, searchorder:=xlByRows)
If Not r Is Nothing Then
r.EntireRow.Font.bold = True

Do
Set r = .FindNext(r)
If Not r Is Nothing Then
r.EntireRow.Font.bold = True
End If
Loop

End If
End With
End Sub
 
R

Ron Rosenfeld

I want to BOLD entire row where a cell contains text "X" in any cell
in
range(active sheet).

I had tried the below macro, it did bold the row contained text "X".
However everytime when I run this macro my excel program hang. Does
anyone has the solution?



Sub PutInBoldXs()
Dim r As Range
With Range("A1:C30")
Set r = .Find("X", LookIn:=xlValues, searchorder:=xlByRows)
If Not r Is Nothing Then
r.EntireRow.Font.bold = True

Do
Set r = .FindNext(r)
If Not r Is Nothing Then
r.EntireRow.Font.bold = True
End If
Loop

End If
End With
End Sub

I would suggest using Conditional Formatting.

You could either set up the sheet that way initially, or run this macro once:


Sub PutInBoldXs()
With Range("A1:C30")
.Cells(1, 1).Select
.FormatConditions.Delete
.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=COUNTIF($A1:$C1,""*X*"")>0"
With .FormatConditions(1).Font
.Bold = True
.Italic = False
End With
End With
End Sub

--ron
 

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

Top