Separate Bold Text from a string

M

Mani

How can i separate bold text from a string

for example

East Doncaster Victoria, Australia

If East doncaster is bold i want to separate it in another column.

thanks
 
B

Bob Phillips

It would need a UDF.

Function GetBold(rng As Range) As String
Dim mStart As Long
Dim mEnd As Long
Dim i As Long

If rng.Cells.Count > 1 Then

GetBold = CVErr(xlErrRef)
Else

Do
mStart = mStart + 1
Loop Until mStart > Len(rng.Value) Or rng.Characters(mStart,
1).Font.Bold

If mStart > Len(rng.Value) Then Exit Function

mEnd = mStart
Do
mEnd = mEnd + 1
Loop Until mEnd <= Len(rng.Value) And Not rng.Characters(mEnd,
1).Font.Bold

GetBold = Mid$(rng.Value, mStart, mEnd - mStart + 1)
End If
End Function
 

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