Macro that delets all cells containg ALL words in bold

A

andrei

I have a macro which delets content from cells if there is bold text in cell
..

Sub Delete_Bold_Text()
Dim i
For Each cell In ActiveSheet.UsedRange
cell.Select
For i = 1 To Len(ActiveCell)
If ActiveCell.Characters(Start:=i, _
Length:=1).Font.Bold = True Then
ActiveCell.ClearContents
End If
Next
Next
End Sub


The problem is that i have cells in which there is "normal" text and bolded
text and i don't want them deleted . I want to be deleted only cells in
which all text is bolded . Can this be done ?
 
D

Dave Peterson

Option Explicit
Sub Delete_Bold_Text2()
Dim myCell As Range
For Each myCell In ActiveSheet.UsedRange.Cells
If myCell.Font.Bold = True Then
myCell.ClearContents
End If
Next myCell
End Sub
 
M

Mike H

Hi,

If you test a cell for bold and only some of the text is bold Excel throws
an error so this can be utilised in the code to simply move on and ignore
that cell.

Sub Delete_Bold_Text()
On Error Resume Next
For Each Cell In ActiveSheet.UsedRange
If Cell.Font.Bold Then
Cell.ClearContents
End If
Next
End Sub

Mike
 

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