+ Reply to Thread
Results 1 to 4 of 4

Extract Bold Text from cell

  1. #1
    Registered User
    Join Date
    04-02-2007
    Posts
    3

    Extract Bold Text from cell

    Hello,

    I have a column of text that has some words that are formatted in "Bold".

    Douglas DC-9 aircraft
    Hughes aircraft

    I was hoping someone here could help me write a vba macro to loop through all the rows and pull out only words in Bold and place them in the adjacent column.

    Thanks in advance.

  2. #2
    Forum Expert
    Join Date
    11-23-2005
    Location
    Rome
    MS-Off Ver
    Ms Office 2016
    Posts
    1,628
    Try with this code:

    Please Login or Register  to view this content.
    I hope it can help you.

    Regards,
    Antonio

  3. #3
    Registered User
    Join Date
    04-02-2007
    Posts
    3
    Thanks Antonio,

    One problem I'm having is that if the first word is Bold (or there is only one word) then Macro skips to the un bold part of the phrase or does nothing.

    I've attached an example.
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    04-02-2007
    Posts
    3
    This fixed my problem

    Sub Macro1()
    Dim txt As String
    lastRow = Cells(Rows.Count, "a").End(xlUp).Row
    For Each c In Range("a1:a" & lastRow).Cells
    myBoldText = ""
    For i = 1 To Len(c.Value)
    If c.Characters(Start:=i, Length:=1).Font.FontStyle = "Bold" Then

    txt = Mid(c.Value, i, 1)
    'text in bold
    myBoldText = myBoldText & txt

    End If
    Next
    c.Offset(0, 1) = myBoldText
    Next
    End Sub

    Thanks for the help.

+ 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