+ Reply to Thread
Results 1 to 4 of 4

Format Part of Text Cell using VBA

  1. #1
    Vlad
    Guest

    Format Part of Text Cell using VBA

    Using Excel 2000 - it is manually possible to create a cell, where the
    first line of text is in italics and the remainder of the text in the
    cell is normally formatted.

    Can you part-format a cell using excel 2k?

    If not can you achieve this on any other versions of excel.

    TIA

    Vlad


  2. #2
    Dave Peterson
    Guest

    Re: Format Part of Text Cell using VBA

    If the value in the cell is a number or the results of a formula, then you can't
    do this kind of formatting.

    But if the value in the cell is text, then
    you can select the cell
    highlight the characters (in the formula bar) that you want to give a special
    format

    and format|Cells
    (or click the icons on the formatting toolbar)

    Vlad wrote:
    >
    > Using Excel 2000 - it is manually possible to create a cell, where the
    > first line of text is in italics and the remainder of the text in the
    > cell is normally formatted.
    >
    > Can you part-format a cell using excel 2k?
    >
    > If not can you achieve this on any other versions of excel.
    >
    > TIA
    >
    > Vlad


    --

    Dave Peterson

  3. #3
    Vlad
    Guest

    Re: Format Part of Text Cell using VBA


    Dave Peterson wrote:
    > If the value in the cell is a number or the results of a formula, then you can't
    > do this kind of formatting.
    >
    > But if the value in the cell is text, then
    > you can select the cell
    > highlight the characters (in the formula bar) that you want to give a special
    > format
    >
    > and format|Cells
    > (or click the icons on the formatting toolbar)
    >



    Sorry Dave - I meant can I do this using VBA


  4. #4
    Vlad
    Guest

    Re: Format Part of Text Cell using VBA

    I have now managed to find a solution:-

    Sub EditFont()
    'To format font color for 12 digits to 4 black, 5 red, 3 black:
    123456789012
    'First, format digits to be treated as characters
    ActiveCell.Value = "'" & ActiveCell.Value
    'Format all characters for black
    With ActiveCell
    ..Font.ColorIndex = 3
    'Format characters 5 thru 12 as red
    ..Characters(1, ActiveCell.Characters.Count - 8).Font.ColorIndex = 1
    'Reformat characters 10 thru 12 back to black
    ..Characters(10, ActiveCell.Characters.Count - 3).Font.ColorIndex = 1
    End With


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1