ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   How to chose bold text in a sentence in Excel? (https://www.excelbanter.com/excel-worksheet-functions/109309-how-chose-bold-text-sentence-excel.html)

Luong Vinh Tu

How to chose bold text in a sentence in Excel?
 
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

Ron Rosenfeld

How to chose bold text in a sentence in Excel?
 
On Sun, 10 Sep 2006 15:58:01 -0700, Luong Vinh Tu <Luong Vinh
wrote:

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


All times are GMT +1. The time now is 03:38 PM.

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