1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Change font color and italicized including brackets update

Discussion in 'Business Applications' started by sukisuki, Jan 7, 2013.

Thread Status:
Not open for further replies.
  1. sukisuki

    sukisuki Thread Starter

    Jan 7, 2013
    Happy New Year to all.

    I'm new here, and this is about Rollin_Again answer to Bibleuser question last July 27, 2012 (Replace contents in brackets with Italicized words and certain font color).

    The formula works to me but, when I run it, it takes away the brackets (in my case parentheses). What I want is change the font color and italicized including the brackets, so the brackets stay. I'm using Excel 2007

    Hoping someone could rewrite the formula for me, I need it very importantly.

    Thank you very much.

    Here's the formula:

    Sub FindBrackets()

    Set vFound = Cells.Find(What:="[*]", _
    After:=ActiveCell, LookAt:=xlPart, SearchOrder:=xlByRows, _
    SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False)

    If Not vFound Is Nothing Then
    Call FormatCell(vFound.Address)
    Set vFound = Cells.FindNext(vFound)
    Loop Until vFound Is Nothing
    MsgBox ("Not Found")
    End If

    End Sub

    Sub FormatCell(vAddress As String)

    Dim aArray() As String

    vCount = 0

    Do While InStr(1, Range(vAddress).Value, "[") > 0 Or InStr(1, Range(vAddress).Value, "]") > 0

    ReDim Preserve aArray(vCount)

    vStart = InStr(1, Range(vAddress).Value, "[") - 1
    vEnd = InStr(1, Range(vAddress).Value, "]") - 1

    Range(vAddress).Value = Replace(Range(vAddress).Value, "[", "", , 1)
    Range(vAddress).Value = Replace(Range(vAddress).Value, "]", "", , 1)

    aArray(vCount) = vStart & "," & vEnd

    vCount = vCount + 1


    For i = 0 To UBound(aArray)
    vStart = CInt(Mid(aArray(i), 1, InStr(1, aArray(i), ",") - 1))
    vEnd = CInt(Mid(aArray(i), InStr(1, aArray(i), ",") + 1))

    Range(vAddress).Characters(Start:=vStart, Length:=(vEnd - vStart + 1)).Font.Color = -16776961
    Range(vAddress).Characters(Start:=vStart, Length:=(vEnd - vStart + 1)).Font.FontStyle = "Italic"

    Next i

    End Sub
  2. etaf

    etaf Moderator

    Oct 2, 2003
    First Name:
As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/1084142

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice