I want to highlight a piece of cell text in OpenOffice.org Calc. But this text is calculated.

If I enter the text into the cell with my hands, I can format any of its fragments: for example, select the first line in bold orange. And how to achieve the same effect, if the line is going to the formula of other cells? Even with simple =A3 formatting is lost.

Screenshot

    1 answer 1

    No, formulas cannot change the cell format. But you can macro.

    In VBA ( MS Excel ), the Characters operator is responsible for formatting a character (block of characters, all text).

    Sample code. In the A2 range : A10 we format some text:

     Sub CharactersText() Dim s As String Dim i As Long, k As Long For i = 2 To 10 ' перебираем 9 ячеек With Cells(i, 1) s = .Value ' текст изменяемой ячейки With .Characters(Start:=1, Length:=7).Font ' формат первых 7 символов .Name = "Arial" ' шрифт .Size = 12 ' размер .Color = RGB(170, 110, 100) ' цвет .Bold = True ' жирный .Italic = True ' курсив .Underline = True ' черта End With End With Next i End Sub 
    • And how is the macro? - Qwertiy
    • added in reply - vikttur
    • It looks like a macro for MS Excel. Does not work in OOo: "BASIC runtime error. The subroutine or function is not defined." on the line s = .Value . - Qwertiy
    • Yes, this is VBA. Excel label is specified. The title does not emphasize OO ... The question may be entered in the search for a solution for MS Excel. Unfortunately, I will not write for OO Calc. - vikttur