Help with applying bold to formula result

cbrf23

Board Regular
Joined
Jun 20, 2011
Messages
241
Hi, I'm trying to figure out how to apply bold to a part of a cell, the contents of which results from a formula.

I have in cell A4:
="DWG NO:" & vlookup another cell
which results in:
DWG NO: 1234-XXX-55-X <--the length of this number can vary.
I want it to be formatted like:
DWG NO: 1234-XXX-55-X

I tried using the characters method to bold everything except "DWG NO:". When I step through the code, I dont get any errors, but even after running the line:
Code:
        With Target
            .Characters(7, intBold).Font.Bold = True
        End With
If I ask in the immediate window the same thing, the value still says false. It never changes...

My code I tried:
Code:
    Dim intBold   As Integer
    Dim strComplete     As String
    Dim strBold         As String
    If Not Intersect(Target, Range("A4")) Is Nothing Then
        strComplete = Target.Text
        strBold = Mid(strComplete, 8)
        intBold = Len(strBold)
        With Target
            .Characters(7, intBold).Font.Bold = True
        End With
    End If
End Sub

Any suggestions??
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
In short....
It cannot be done.
Excel/VBA cannot format a portion of a formula's result. Period.
It can only format the ENTIRE result of a formula.

The only way to do it is to convert the formula to it's value.
Copy - Paste Special - Values
THEN you can format only a portion of the cell.
 
Upvote 0
Well thatis what I was afraid of... Guess I will have to change my layout a bit then. might try to play a bit with is work around then...
 
Upvote 0

Forum statistics

Threads
1,224,552
Messages
6,179,487
Members
452,917
Latest member
MrsMSalt

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top