I have a spreadsheet where in order to code the importance of one word
over another in a string words were entered in a bold in the string.
Is there a function I can use to identify bold text in a string so it
can be separated into a new column?
I have a spreadsheet where in order to code the importance of one word
over another in a string words were entered in a bold in the string.
Is there a function I can use to identify bold text in a string so it
can be separated into a new column?
You could use a userdefined function to extract the bold characters:
Option Explicit
Function GetBoldChars(myCell As Range) As String
Application.Volatile True
Dim iCtr As Long
Dim OutStr As String
Set myCell = myCell.Cells(1) 'one cell at a time
OutStr = ""
If myCell.Font.Bold = True Then
OutStr = myCell.Value
Else
If myCell.Font.Bold = False Then
OutStr = ""
Else
For iCtr = 1 To Len(myCell.Value)
If myCell.Characters(Start:=iCtr, Length:=1).Font.Bold _
= True Then
OutStr = OutStr & Mid(myCell.Value, iCtr, 1)
End If
Next iCtr
End If
End If
GetBoldChars = OutStr
End Function
Be aware that if you change the formatting of the cell, then this formula cell
won't change until your workbook calculates.
If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm
Short course:
Open your workbook.
Hit alt-f11 to get to the VBE (where macros/UDF's live)
hit ctrl-R to view the project explorer
Find your workbook.
should look like: VBAProject (yourfilename.xls)
right click on the project name
Insert, then Module
You should see the code window pop up on the right hand side
Paste the code in there.
Now go back to excel.
Into a test cell and type:
=GetBoldChars(a1)
william kossack wrote:
>
> I have a spreadsheet where in order to code the importance of one word
> over another in a string words were entered in a bold in the string.
>
> Is there a function I can use to identify bold text in a string so it
> can be separated into a new column?
--
Dave Peterson
a sub for the active cell
Sub findboldincell()
Set ac = Selection
For i = 1 To Len(ac)
If ac.Characters(i, 1).Font.Bold Then
ms = ms & Mid(ac, i, 1)
End If
Next i
ac.Offset(, 1) = ms
End Sub
--
Don Guillett
SalesAid Software
[email protected]
"william kossack" <[email protected]> wrote in message
news:[email protected]...
> I have a spreadsheet where in order to code the importance of one word
> over another in a string words were entered in a bold in the string.
>
> Is there a function I can use to identify bold text in a string so it
> can be separated into a new column?
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks