Solved

How to change the font of specific substrings in excel workbook

Posted on 2015-01-20
2
31 Views
Last Modified: 2016-08-28
I would like to bold and change the font color of a substring in an excel workbook with multiple worksheets.  All of the cells in the workbook have text.  Using the Excel Replace command changes the entire text in the cell.

Seems like a basic need, but either I'm missing something, or it requires a macro of some sorts to do this.

Thanks,
Bret
0
Comment
Question by:Bret
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 42

Accepted Solution

by:
pcelba earned 500 total points
ID: 40560942
I've found following way which uses IE to create the right format:
Sub Sample()
    Dim Ie As Object

    Set Ie = CreateObject("InternetExplorer.Application")

    With Ie
        .Visible = False

        .Navigate "about:blank"

        .document.body.InnerHTML = "<html><p>This is <b>bold</b> or <i>italic</i></p></html>"

        .document.body.createtextrange.execCommand "Copy"
        ActiveSheet.Paste Destination:=Sheets("Sheet1").Range("A1")

        .Quit
    End With
End Sub

Open in new window

So you may try colors (the whole cell must have one back color) and fonts.

You don't need IE in fact... Following OLE Automation code also works, so it could give you some ideas... (the conversion to VBA should be easy):
oex = CREATEOBJECT('excel.application')
oex.Visible = .t.
oex.Workbooks.Add
_cliptext =  '<html><p>This is <b>bold</b> or <i>italic</i><font size="3" color="red"> red text!</font></p></html>'
oex.ActiveSheet.Range('A2').PasteSpecial

Open in new window

0

Featured Post

Percona Live Europe 2017 | Sep 25 - 27, 2017

The Percona Live Open Source Database Conference Europe 2017 is the premier event for the diverse and active European open source database community, as well as businesses that develop and use open source database software.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
Ever visit a website where you spotted a really cool looking Font, yet couldn't figure out which font family it belonged to, or how to get a copy of it for your own use? This article explains the process of doing exactly that, as well as showing how…
The viewer will learn how to simulate a series of coin tosses with the rand() function and learn how to make these “tosses” depend on a predetermined probability. Flipping Coins in Excel: Enter =RAND() into cell A2: Recalculate the random variable…
The view will learn how to download and install SIMTOOLS and FORMLIST into Excel, how to use SIMTOOLS to generate a Monte Carlo simulation of 30 sales calls, and how to calculate the conditional probability based on the results of the Monte Carlo …
Suggested Courses

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question