How to chose bold text in a sentence in Excel?

G

Guest

I have a text in a cell
Barcelona vs Osasuna ("Barcelona" is bold)
Now I want to chose the text "Barcelona"
How to do this ?
Thanks
 
R

Ron Rosenfeld

On Sun, 10 Sep 2006 15:58:01 -0700, Luong Vinh Tu <Luong Vinh
I have a text in a cell
Barcelona vs Osasuna ("Barcelona" is bold)
Now I want to chose the text "Barcelona"
How to do this ?
Thanks

Not sure what you mean when you write "chose the text".

If you want to select it, double click in the cell and drag the cursor across
the bold letters. You can then copy it and paste it elsewhere.

If you want a function to return all of the bolded text in a cell as the
result, then you will need to use a VBA function.

<alt><F11> opens the VB Editor.
Ensure your project is highlighted in the project explorer window, then
Insert/Module and paste the code below into the window that opens.

To use the function (UDF), enter a formula into some cell in the form:

=SelBold(cell_ref)

where cell_ref is the cell containing your partially bolded string.

============================================
Option Explicit

Function SelBold(rg As Range) As String
Dim i As Long

For i = 1 To Len(rg.Text)
If rg.Characters(i, 1).Font.Bold = True Then
SelBold = SelBold & Mid(rg.Text, i, 1)
End If
Next i

End Function
============================


--ron
 
R

Ron Rosenfeld

On Sun, 10 Sep 2006 15:58:01 -0700, Luong Vinh Tu <Luong Vinh
I have a text in a cell
Barcelona vs Osasuna ("Barcelona" is bold)
Now I want to chose the text "Barcelona"
How to do this ?
Thanks

Not sure what you mean when you write "chose the text".

If you want to select it, double click in the cell and drag the cursor across
the bold letters. You can then copy it and paste it elsewhere.

If you want a function to return all of the bolded text in a cell as the
result, then you will need to use a VBA function.

<alt><F11> opens the VB Editor.
Ensure your project is highlighted in the project explorer window, then
Insert/Module and paste the code below into the window that opens.

To use the function (UDF), enter a formula into some cell in the form:

=SelBold(cell_ref)

where cell_ref is the cell containing your partially bolded string.

============================================
Option Explicit

Function SelBold(rg As Range) As String
Dim i As Long

For i = 1 To Len(rg.Text)
If rg.Characters(i, 1).Font.Bold = True Then
SelBold = SelBold & Mid(rg.Text, i, 1)
End If
Next i

End Function
============================


--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