+ Reply to Thread
Results 1 to 3 of 3

determining bold font in a string

  1. #1
    william kossack
    Guest

    determining bold font in a string

    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?

  2. #2
    Dave Peterson
    Guest

    Re: determining bold font in a string

    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

  3. #3
    Don Guillett
    Guest

    Re: determining bold font in a string

    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?




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1