Mrrrr's Forum (VIEW ONLY)
Un forum care ofera solutii pentru unele probleme legate in general de PC. Pe langa solutii, aici puteti gasi si alte lucruri interesante // A forum that offers solutions to some PC related issues. Besides these, here you can find more interesting stuff.
Lista Forumurilor Pe Tematici
Mrrrr's Forum (VIEW ONLY) | Reguli | Inregistrare | Login

POZE MRRRR'S FORUM (VIEW ONLY)

Nu sunteti logat.
Nou pe simpatie:
angy_2 Profile
Femeie
21 ani
Constanta
cauta Barbat
21 - 63 ani
Mrrrr's Forum (VIEW ONLY) / Tutoriale si Ghiduri Utile // Tutorials and useful guides / [EXCEL] Color Text Inside Cell Comment [VBA] Moderat de TRaP, TonyTzu
Autor
Mesaj Pagini: 1
TRaP
Moderator

Inregistrat: acum 6 ani
Postari: 772
With default Excel functions you can't select text inside a comment and change its color. You can bold, underline or make it italic, but not color it.

But fortunately you can with VBA. The code below offers the text in the comment in an InputBox, where you have to leave only the text you want to color and delete the rest, then upon clicking OK the text is colored.

This was made from site 1 in sources and from

The code below can be further developed.



Sub Comment_Color()

Dim i, n As Long
Dim txt As String
Dim rng As Range
Dim com_txt As String
Dim cnt As Integer

Set rng = ActiveCell
    com_txt = rng.Comment.Text
   
    txt = InputBox("Leave only words you want to color blue", "Characters...", com_txt)
    If txt = "" Then Exit Sub

' CASE SENSITIVE
    cnt = (Len(com_txt) - Len(Replace(com_txt, txt, ""))) / Len(txt)

For i = 1 To cnt
    n = InStr(n + i, com_txt, txt)
    rng.Comment.Shape.TextFrame.Characters(n, Len(txt)).Font.ColorIndex = 5
Next i
   
End Sub


Sources to test/analyze:


pus acum 4 ani
   
Pagini: 1  

Mergi la