One way:
This assumes there's only one <b</b pair - you could use recursion if
you expect more than one.
Dim str As String
Dim nBold As Long
Dim nEndBold As Long
Dim nChars As Long
With ActiveCell
str = .Text
nBold = InStr(str, "<b")
If nBold 0 Then
nEndBold = InStr(str, "</b")
If nEndBold = 0 Then nEndBold = 32767
nChars = nEndBold - nBold - 3
str = Replace(Replace(str, "<b", ""), "</b", "")
.Value = str
.Characters(nBold, nChars).Font.Bold = True
End If
End With
For XL97 or MacXL, replace Replace with Application.Substitute
In article ,
(Matt) wrote:
I have some data that I pull from an external database and just
display it in an excel cell using VB. I currently strip out all of
the html tags and convert the <br to line feeds. That works great.
But I would like to convert <b tags within the cell to bold.
So my cell might contain: "This is a <bformatting</b test."
I am trying to figure out a way to make the word formatting in the
example above bold. Can anyone help?
Thanks,
Matt