Format a subset of text in an Excel cell using a formula

I built a string using a formula in excel. as an example

Cell C3 contains the text "Languages"
Cell C4 = "English, Spanish, German, French"
My Forumla = C3 and ":" and CHAR (10) and C4

Desired text:

Languages:
English, Spanish, German, French

(where the bold text will actually have some color like red)

Is there a way to do this in Excel (change partial text formatting).

I tried the formula ... (doesn't work)

Function formatText(InText As Range)

'Set font color
  InText.Characters(1.5).Font.Color = Red
   'InText.Characters((InStr(1, ":", InText) + 1), (Len(InText) - InStr(1, ":", InText))).Font.ColorIndex = 3
End Function
+5
source share
4 answers

Your published function only works when

  • Sub (.. , UDF)

  • (), InText, . ( )

InText, . AFAIK , .

, , !

+4

Hightower: " , ?"

"" , , , , , , . , ( ), ( , ).

Sub Cell_Format(InText as Range)
  InText.formula = cstr(InText.value)  ' converts result of formula into a string literal   
    'or: InText.offset(0,1).formula = cstr(InText.value) -- writes the value in the cell next to InText
  InText.characters(1, 5).font.color = vbRed
End Sub

Cell_Format range("$A$1") $A $1 .

, , :

Sub Range_Format(InText as Range)
  For each c in InText
    Cell_Format(c)
  Next
End Sub
+1

UDF Excel. , UDF . . http://support.microsoft.com/kb/170787

Function formatText(InText As Range)

'Set font color
  InText.Interior.Color = vbRed
   'InText.Characters((InStr(1, ":", InText) + 1), (Len(InText) - InStr(1, ":", InText))).Font.ColorIndex = 3
End Function
0

:

InText.Characters(1,5).Font.Color = RGB(255, 0, 0)

, () , :

InText.Characters(Instr(InText, vbCr)+1, Len(InText)-Instr(InText, vbCr)).Font.Color = RGB(255, 0, 0)

, VBA, .. ! UDF , !

0

All Articles