Manolocs
Active Member
- Joined
- Mar 28, 2008
- Messages
- 340
Hello, I got this Function from Mr. Peter_SSs, it is working perfect, the function split Bold Words from not Bold.
My questions is, Can this function be changed to look for (italic and Capital letters font) instead of Bold? I don't need both together but would be good to have one function for each one.
Thanks in advance.
My questions is, Can this function be changed to look for (italic and Capital letters font) instead of Bold? I don't need both together but would be good to have one function for each one.
Thanks in advance.
Code:
[COLOR=darkblue]Function[/COLOR] SplitBold(r [COLOR=darkblue]As[/COLOR] Range, [COLOR=darkblue]Optional[/COLOR] bBold [COLOR=darkblue]As[/COLOR] [COLOR=darkblue]Boolean[/COLOR] = [COLOR=darkblue]True[/COLOR]) [COLOR=darkblue]As[/COLOR] [COLOR=darkblue]String[/COLOR]
[COLOR=darkblue]Dim[/COLOR] i [COLOR=darkblue]As[/COLOR] [COLOR=darkblue]Long[/COLOR], pos [COLOR=darkblue]As[/COLOR] [COLOR=darkblue]Long[/COLOR]
[COLOR=darkblue]Dim[/COLOR] Words [COLOR=darkblue]As[/COLOR] [COLOR=darkblue]Variant[/COLOR]
[COLOR=darkblue]Dim[/COLOR] sBold [COLOR=darkblue]As[/COLOR] [COLOR=darkblue]String[/COLOR], sUnbold [COLOR=darkblue]As[/COLOR] [COLOR=darkblue]String[/COLOR]
[COLOR=darkblue]If[/COLOR] r.Cells.Count = 1 And Len(r.Cells(1).Value) [COLOR=darkblue]Then[/COLOR]
Words = Split(r.Value)
pos = 1
[COLOR=darkblue]For[/COLOR] i = 0 [COLOR=darkblue]To[/COLOR] [COLOR=darkblue]UBound[/COLOR](Words)
[COLOR=darkblue]If[/COLOR] r.Characters(pos, 1).Font.Bold [COLOR=darkblue]Then[/COLOR]
sBold = sBold & " " & Words(i)
[COLOR=darkblue]Else[/COLOR]
sUnbold = sUnbold & " " & Words(i)
[COLOR=darkblue]End[/COLOR] [COLOR=darkblue]If[/COLOR]
pos = pos + Len(Words(i)) + 1
[COLOR=darkblue]Next[/COLOR] i
[COLOR=darkblue]If[/COLOR] bBold [COLOR=darkblue]Then[/COLOR]
SplitBold = Mid(sBold, 2)
[COLOR=darkblue]Else[/COLOR]
SplitBold = Mid(sUnbold, 2)
[COLOR=darkblue]End[/COLOR] [COLOR=darkblue]If[/COLOR]
[COLOR=darkblue]End[/COLOR] [COLOR=darkblue]If[/COLOR]
End [COLOR=darkblue]Function[/COLOR]