+ Reply to Thread
Results 1 to 4 of 4

concatenate + format color

  1. #1
    Thierry
    Guest

    concatenate + format color

    Hello,
    With the function concatenate, how can we
    A) Ask to get the same format as the original cell
    B) Force a color format, like red
    Exemple = concatenate(A1; " "; A2; " "; A3)
    I would like that
    1) A1 displays the same color and number format as the cell A1 (for example
    green with number #'##0.00
    2) Force the format of A2 in red

    I know that the function TEXT exists
    =concatenate(TEXT (A1;"#'##0.00"); etc.)
    But how can I say "red" or "same format as cell A1" ?
    Thank you for all advise



  2. #2
    David Adamson
    Guest

    Re: concatenate + format color


    See the help file on colorIndex for more info but basically its

    Worksheets("Sheet1").Range("D19").Font.ColorIndex = 3


    "Thierry" <[email protected]> wrote in message
    news:[email protected]...
    > Hello,
    > With the function concatenate, how can we
    > A) Ask to get the same format as the original cell
    > B) Force a color format, like red
    > Exemple = concatenate(A1; " "; A2; " "; A3)
    > I would like that
    > 1) A1 displays the same color and number format as the cell A1 (for
    > example green with number #'##0.00
    > 2) Force the format of A2 in red
    >
    > I know that the function TEXT exists
    > =concatenate(TEXT (A1;"#'##0.00"); etc.)
    > But how can I say "red" or "same format as cell A1" ?
    > Thank you for all advise
    >




  3. #3
    Rowan
    Guest

    Re: concatenate + format color

    A formula cannot be used to modifiy the format of a cell, it just
    returns a value.

    Excel (2002/2003) will allow you to part format the font of a cell if it
    contains text but not if it contains a formula. So if you want your
    result to be dynamic and keep the formula in the cell I don't believe
    you can have different font colours.

    If you are happy to replace the formula with its result in text format
    then you could do it with a macro like this (select the cell containing
    the formula first):

    Sub FText()
    Dim Prec As Range
    Dim cell As Range
    Dim TLen As Integer
    Set Prec = ActiveCell.DirectPrecedents
    TLen = 1
    With ActiveCell
    .NumberFormat = "@"
    .Value = .Value
    End With
    For Each cell In Prec
    ActiveCell.Characters(TLen, Len(cell.Text)).Font.ColorIndex = _
    cell.Font.ColorIndex
    TLen = TLen + Len(cell.Text)
    Next cell
    End Sub


    Hope this helps
    Rowan


    Thierry wrote:
    > Hello,
    > With the function concatenate, how can we
    > A) Ask to get the same format as the original cell
    > B) Force a color format, like red
    > Exemple = concatenate(A1; " "; A2; " "; A3)
    > I would like that
    > 1) A1 displays the same color and number format as the cell A1 (for example
    > green with number #'##0.00
    > 2) Force the format of A2 in red
    >
    > I know that the function TEXT exists
    > =concatenate(TEXT (A1;"#'##0.00"); etc.)
    > But how can I say "red" or "same format as cell A1" ?
    > Thank you for all advise
    >
    >


  4. #4
    Jim Thomlinson
    Guest

    RE: concatenate + format color

    Concatenate only deals with the values of the cells and not with the formats
    applied to those cells. In order to concatenate and apply colour would
    require a bunch of code (assuming you want different formats for each cell
    being concatenated). Otherwise just format the cell with the concatenate
    formula.
    --
    HTH...

    Jim Thomlinson


    "Thierry" wrote:

    > Hello,
    > With the function concatenate, how can we
    > A) Ask to get the same format as the original cell
    > B) Force a color format, like red
    > Exemple = concatenate(A1; " "; A2; " "; A3)
    > I would like that
    > 1) A1 displays the same color and number format as the cell A1 (for example
    > green with number #'##0.00
    > 2) Force the format of A2 in red
    >
    > I know that the function TEXT exists
    > =concatenate(TEXT (A1;"#'##0.00"); etc.)
    > But how can I say "red" or "same format as cell A1" ?
    > Thank you for all advise
    >
    >
    >


+ 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