Replace bold with Blank

jiggly

New Member
Joined
Jun 1, 2011
Messages
42
I am looking for the proper syntax to replace any bold text with blank text...
I am currently using this:

=SUBSTITUTE('BOOK1'!G1, "some text", "")

It just replaces any instances of "some text" with nothing, and this works fine, however, i would like to make it a little more general.

Ideally, i would like to use replace any bold font with no text, but i can't figure out the syntax

=REPLACE('BOOK1'!G1.font.bold, "") or something like that
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
Welcome to the forums!

You'll need to use a VBA function for this, try the following Custom Function:

Code:
Public Function ReplaceBold(rng As Range)
Dim i   As Long
If Len(rng.Value) > 0 Then
    For i = 1 To Len(rng.Value)
        If Mid$(rng.Value, i, 1) <> " " Then
            If rng.Characters(Start:=i, Length:=1).Font.Bold = False Then
                ReplaceBold = ReplaceBold & Mid$(rng.Value, i, 1)
            End If
        Else
            ReplaceBold = ReplaceBold & " "
        End If
    Next i
End If
End Function

To use this, do the following:
  1. Press Alt+F11 to open the VBA Editor
  2. Insert>Module
  3. Copy/paste the above code into the module
  4. Go back to your worksheet and use the function =REPLACEBOLD(range)
 
Upvote 0
As far as I'm aware, no native excel formulas can look at the formatting of individual characters.
 
Upvote 0
worked fairly well, however, i got some fields blank, and others with a "0" in them afterward.... any ideas?
 
Upvote 0
Can you please provide some examples of what didn't give the proper result, as well as what your desired result is? It seemed to work fine on my end.
 
Upvote 0
I'm looking at your file now. For the fields that are blank, I'm assuming you want them blank, as the entire content of those fields is bold?
 
Upvote 0
Yes, all the fields that are blank should remain blank, and all fields that are bold should become blank as well....

I'm not sure why zeros are showing up at all....
 
Upvote 0
ok, i rebuilt the sheet from scratch, and am no longer having the problem.... some kind of formatting must have been stuck in there, but for the life of me, i couldn't find it.....
no worries..... I do have another function i would like to add however.

The output is exactly what I want, and manually, I can remove the blank rows, but when I try it with a macro, the result returns a #VALUE! error.

Why can i remove the blank rows manually, but not with a macro?
 
Upvote 0
What is the macro you are trying to use to remove blank rows?
 
Upvote 0

Forum statistics

Threads
1,224,566
Messages
6,179,551
Members
452,927
Latest member
rows and columns

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top